Open the lookup dialog of a field in CRM 2011 from javascript

975 views Asked by At

How can I launch the lookup dialog of a lookup field, using javascript?

1

There are 1 answers

4
Donal On BEST ANSWER

Here is an example of how to launch the lookup dialog from a custom page - based on CRM2011 (post Rollup 12).

var organizationUrl = "http://servername:5555/organizationName";

//Object Type Code of the entity which needs to be shown in the Lookup.
var objectTypeCode = 1000;

var urlToOpen = organizationUrl + "/_controls/lookup/lookupinfo.aspx?LookupStyle=single&browse=0&showpropbutton=1&AllowFilterOff=1&objecttypes=" + objectTypeCode;

//Get the modal window    
var modalWindow = JSON.parse(window.showModalDialog(urlToOpen, " ", "dialogHeight:600px;"));

//Selected Id will be returned here    
var selectedItemId = modalWindow.items[0].id;