Display/Show CRM default Lookup(Lookup more records) window using Javascript
If you have any doubt in the post please post comments. I will try to solve your problem.
With the help of java-script we can display CRM lookup more records form for any entity .
URL:/_controls/lookup/lookupinfo.aspx?paremeter
Parameter:
&DefaultType=ObjectTypeCode
&DefaultViewId= ViewId
&DisableQuickFind=0(Do you want quick find enable or not disable) Enable=1 Disable=0
&DisableViewPicker=0(Do you want quick view picker enable or not disable)
&IsInlineMultiLookup=0
&LookupStyle=Lookup Style(single)
&ShowNewButton=1 (Do you want new button enable or not disable)
&ShowPropButton=1 (Do you want prop button enable or not disable)
&dType=1
&mrsh=false
&objecttypes=ObjectTypeCode
&search=Searchstring
Example:
var strSearch = Xrm.Page.getAttribute('shipto_postalcode').getValue();
var strURL = "_controls/lookup/lookupinfo.aspx?AllowFilterOff=0&DefaultType=10161&DefaultViewId=%7b141FCA27-5F72-E511-9418-0050568107AE%7d&DisableQuickFind=0&DisableViewPicker=0&IsInlineMultiLookup=0&LookupStyle=single&ShowNewButton=0&ShowPropButton=1&dType=1&mrsh=false&objecttypes=10161&search=";
strURL += strSearch;
var oUrl = Mscrm.CrmUri.create(strURL);
var dialogwindow = new Mscrm.CrmDialog(oUrl, window, 500, 600);
//use setCallbackReference method to call some handler once dialog is closed
//to result variable would be returned result of dialog call
dialogwindow.setCallbackReference(function(result) {
});
//call this method to show dialog
dialogwindow.show();
Filter types in CRM lookup window:
1) Filter a single columns( where country='usa') in the lookup window grid.
Solution:
It is possible in both CRM On-Premises and On-line.The value can be set both dynamically and static value.
Static:
Customization->Entity->views->Add filter in that form. Call that form in javascript.
Dynamic:
Pass the filter value in the "lookupinfo,aspx" query string with key name search.
2) Filter multi-column( where country='usa' and state='ny') in the lookup window grid
Solutions:
The value can be set both dynamically and static in CRM On-Premises but in CRM online the only static value can be possible,because we can't able to access server page in CRM online.
Static:
Customization->Entity->views->Add filter in that form. Call that form in javascript.
Dynamic:
To copy the lookupSingle.aspx (C:\Program Files\Microsoft Dynamics CRM\CRMWeb\_controls\lookup\lookupSingle.aspx) form in server and create a new aspx form in server. When you call this form in javascript pass your own parameter in the query string. In the aspx form you get that value and add filter in the fetch xml and load the grid.
If you have any doubt in the post please post comments. I will try to solve your problem.
With the help of java-script we can display CRM lookup more records form for any entity .
URL:/_controls/lookup/lookupinfo.aspx?paremeter
Parameter:
&DefaultType=ObjectTypeCode
&DefaultViewId= ViewId
&DisableQuickFind=0(Do you want quick find enable or not disable) Enable=1 Disable=0
&DisableViewPicker=0(Do you want quick view picker enable or not disable)
&IsInlineMultiLookup=0
&LookupStyle=Lookup Style(single)
&ShowNewButton=1 (Do you want new button enable or not disable)
&ShowPropButton=1 (Do you want prop button enable or not disable)
&dType=1
&mrsh=false
&objecttypes=ObjectTypeCode
&search=Searchstring
Example:
var strSearch = Xrm.Page.getAttribute('shipto_postalcode').getValue();
var strURL = "_controls/lookup/lookupinfo.aspx?AllowFilterOff=0&DefaultType=10161&DefaultViewId=%7b141FCA27-5F72-E511-9418-0050568107AE%7d&DisableQuickFind=0&DisableViewPicker=0&IsInlineMultiLookup=0&LookupStyle=single&ShowNewButton=0&ShowPropButton=1&dType=1&mrsh=false&objecttypes=10161&search=";
strURL += strSearch;
var oUrl = Mscrm.CrmUri.create(strURL);
var dialogwindow = new Mscrm.CrmDialog(oUrl, window, 500, 600);
//use setCallbackReference method to call some handler once dialog is closed
//to result variable would be returned result of dialog call
dialogwindow.setCallbackReference(function(result) {
});
//call this method to show dialog
dialogwindow.show();
Filter types in CRM lookup window:
- Filter a single column in the lookup window
- Filter multiple column in the lookup window
1) Filter a single columns( where country='usa') in the lookup window grid.
Solution:
It is possible in both CRM On-Premises and On-line.The value can be set both dynamically and static value.
Static:
Customization->Entity->views->Add filter in that form. Call that form in javascript.
Dynamic:
Pass the filter value in the "lookupinfo,aspx" query string with key name search.
2) Filter multi-column( where country='usa' and state='ny') in the lookup window grid
Solutions:
The value can be set both dynamically and static in CRM On-Premises but in CRM online the only static value can be possible,because we can't able to access server page in CRM online.
Static:
Customization->Entity->views->Add filter in that form. Call that form in javascript.
Dynamic:
To copy the lookupSingle.aspx (C:\Program Files\Microsoft Dynamics CRM\CRMWeb\_controls\lookup\lookupSingle.aspx) form in server and create a new aspx form in server. When you call this form in javascript pass your own parameter in the query string. In the aspx form you get that value and add filter in the fetch xml and load the grid.


