我有一小段 Javascript 可以将某些表单的字段设置为可选。
我检查了很多次语法,检查了 CRM 表单中的执行顺序,没有对其他 JS 库的引用。
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");
}
}
我得到的错误似乎与一般语法问题有关:
ReferenceError: getName is not defined
at eval (eval at RunHandlerInternal
at RunHandlerInternal
at RunHandlers
at OnScriptTagLoaded
最佳答案
似乎您在表单上的事件触发器可能被配置为调用名为 getName
的函数...
如果您检查表单 Properties > Events,您是否在 OnLoad 事件中看到对 getName
的调用?根据上面的函数名称,您需要它来调用 getFormName
。
为了记录,Xrm.Page is deprecated赞成传递执行上下文并使用 executionContext.getFormContext()
(除了从 Web 资源引用父页面时,在这种情况下仍然支持 Xrm.Page,这是我最后听说的。)
关于javascript - Dynamics CRM - JS ReferenceError "X"未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57364342/