Created
April 23, 2021 22:09
-
-
Save melamriD365/6909c2b4bd370dab99cce788ffffd218 to your computer and use it in GitHub Desktop.
Open all lookups in a modal dialog across the CRM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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