Skip to content

Instantly share code, notes, and snippets.

@melamriD365
Created April 23, 2021 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melamriD365/6909c2b4bd370dab99cce788ffffd218 to your computer and use it in GitHub Desktop.
Save melamriD365/6909c2b4bd370dab99cce788ffffd218 to your computer and use it in GitHub Desktop.
Open all lookups in a modal dialog across the CRM
if (typeof (MEA) == "undefined") { MEA = {} };
if (typeof (MEA.Utilities) == "undefined") { MEA.Utilities = {} };
MEA.Utilities = {
onLoad:function(primaryControl, cmdProperties){
var formContext = primaryControl;
this.openModalFormForAllLookupFields(formContext);
},
openModalFormForAllLookupFields: function(formContext){
var attributes = formContext.data.entity.attributes;
attributes.forEach(att => {
att.getAttributeType() == 'lookup' ?
formContext.getControl(att.getName()).addOnLookupTagClick(this.openModalForm)
: null
});
},
openModalForm: function (executionContext) {
var formContext = executionContext.getFormContext();
var record = executionContext.getEventArgs().getTagValue();
executionContext.getEventArgs().preventDefault();
var pageInput = {pageType: "entityrecord",entityName: record.entityType,entityId: record.id};
var navigationOptions = {target: 2,width:{value: 80,unit: "%"}};
Xrm.Navigation.navigateTo(pageInput,navigationOptions);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment