Show a Modal Dialog and return a lookup
The following code snippet shows you how to return a lookup from a modal dialog.
I used this code to replace a standard CRM 4 Lookup and display my own custom made lookup screen. When clicking OK in this custom screen a lookup should be returned with the Entity the user has selected in the Custom Lookup.
Place this function in the CRM Form.
document.CustomLookup = function ()
{
var url = “/ISV//CustomLookup.aspx?orgname=” + ORG_UNIQUE_NAME;
var selectedItems = window.showModalDialog(url, null, ‘dialogWidth:600px;dialogHeight:400px;resizable:yes’);
if (selectedItems != null){
crmForm.all.myField.DataValue = selectedItems ;
crmForm.all. myField.FireOnChange(); // If you also need to fire the onchange event
}
}
Then use this function as the onclick event of the Lookup.
try
{
var BlueprintLookup = crmForm.all.metris_blueprintid;
BlueprintLookup.onclick = document.LookupBlueprint;
} catch (e) {}
In the CustomLookup.aspx page add a Gridview that is populated with the entities you need. And add a JavaScript function that will retrieve the selected item in the grid. (I usually work with a SelectedRow style)
http://kennyvaes.wordpress.com/2009/03/10/show-a-modal-dialog-and-return-a-lookup/

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home