Reputation: 13
I have a short bit of Javascript that sets fields to optional for certain forms.
I've checked syntax multiple times, checked the execute order in the CRM Form, and there are no references to other JS Libraries.
function getFormName() {
var formName;
formName = Xrm.Page.ui.formSelector.getCurrentItem().getLabel();
if (formName == "EPS Plan Form") {
Xrm.Page.getAttribute("abc_plan_type").setRequiredLevel("none");
Xrm.Page.getAttribute("usi_erisa_plan").setRequiredLevel("none");
Xrm.Page.getAttribute("abc_product").setRequiredLevel("none");
}
}
The error I'm getting seems to be in reference to general syntax issues :
ReferenceError: getName is not defined
at eval (eval at RunHandlerInternal
at RunHandlerInternal
at RunHandlers
at OnScriptTagLoaded
Upvotes: 1
Views: 2825
Reputation: 3935
Seems like your event trigger on the form might be configured to call a function called getName
...
If you check the form Properties > Events, do you see a call to getName
in the OnLoad event? Based on your function name above you'd need it to call getFormName
.
And for the record, Xrm.Page is deprecated in favor of passing execution context and using executionContext.getFormContext()
(except when referencing the parent page from a web resource, in which case Xrm.Page is still supported, last I heard.)
Upvotes: 2