Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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