web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

HowTo: Open standard lookup window and get selected record(s)

a33ik Profile Picture a33ik 84,331 Most Valuable Professional
If you are apologist of 100% supported solutions for Dynamics CRM this is a good place to close this article because it describes approach that will allow to open standard lookup dialog window of CRM and get selected values from it. Of course that customization is unsupported.
To use standard lookup control you can use following code:

function OpenLookup() {
var lookupurl = "/_controls/lookup/lookupinfo.aspx?" +
"AllowFilterOff=0&DefaultType=2&DisableQuickFind=0&DisableViewPicker=0&IsInlineMultiLookup=0" +
"&LookupStyle=single&ShowNewButton=1&ShowPropButton=1&browse=false&objecttypes=2";
var dialogwindow = new Mscrm.CrmDialog(Mscrm.CrmUri.create(lookupurl), window, 500, 500);
dialogwindow.setCallbackReference(function (result) {
alert(result.items.length + " records were selected");

for (var i = 0; i < result.items.length; i++) {
alert(result.items[i].typename + " with name " + result.items[i].name + " and id " + result.items[i].id + " was selected in lookup");
}
});
dialogwindow.show();
}


In this sample after OpenLookup function was called user will get single contact lookup form opened with all controls available like view dropdown, quick find box, new and properties button. In case you want to customize lookup window you can play with parameters from url.In case you will use this script in your Html webresource don’t forget to add reference to ClientGlobalContext.js.aspx.

I’ve tested this approach for CRM 2013 and 2015. In case it doesn’t work – that means that you’ve done something wrong or this approach is not available because it is not supported ;)

This was originally posted here.

Comments

*This post is locked for comments