One feature of Dialogs is the ability to prompt the user for a record to interact with i.e. prompt for a lookup response.
This blog fulfil the Requirement Like we have a custom Button on the Form/Ribbon and onclick of this button i need to create a lookup for an Entity which looks similar to CRM Lookup.
Here is the code which i have used to get the solution.
var url = "/_controls/lookup/lookupsingle.aspx?objecttypes=" + objectTypeCode;
var DialogOptions = new Xrm.DialogOptions();
DialogOptions.width = 500;
DialogOptions.height = 300;
Xrm.Internal.openDialog(Mscrm.CrmUri.create(url).toString(), DialogOptions, null, null, returnDialogResponse);
objectTypeCode:- You Need to provide a objectTypecode value of the Entity on which Entity the lookup is going to be created But I Recommend to get the "objectTypecode" dynamically by passing Schema Name of the Entity because when the solution is Export/Import then this Entity objectTypeCode may differ from different Machine.
Here i am providing a method which help you to get the objectTypeCode of an Entity by passing the Schema Name of an Entity.
function getEntityObjectTypeCodeByName(entitySchemaName) {
try {
var lookupService = new window.parent.RemoteCommand("LookupService", "RetrieveTypeCode");
lookupService.SetParameter("entityName", entityName);
var result = lookupService.Execute();
if (result.Success && typeof result.ReturnValue == "number") {
return result.ReturnValue;
} else {
return null;
}
}
catch (e) {
alert("Error getting ETC by Name – " + e.description);
}
}
Hope this will be Helpful in your CRM custom development.
No comments:
Post a Comment