Skip to content

Instantly share code, notes, and snippets.

@melamriD365
Created April 23, 2021 21:44
Show Gist options
  • Save melamriD365/75d6e97fbd10b678459f25b765ace703 to your computer and use it in GitHub Desktop.
Save melamriD365/75d6e97fbd10b678459f25b765ace703 to your computer and use it in GitHub Desktop.
Open all lookups in a modal dialog
if (typeof (MEA) == "undefined") { MEA = {} };
if (typeof (MEA.Account) == "undefined") { MEA.Account = {} };
if (typeof (MEA.Account.AccountForm) == "undefined") { MEA.Account.AccountForm = {} };
MEA.Account.AccountForm = {
onLoad: function (executionContext) {
var formContext = executionContext.getFormContext();
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