[英]Javascript in CRM 2011
Statutory Disclaimer: New to JavaScript 法定免责声明:JavaScript新手
Form : MyForm 形式 :MyForm
Fields : 领域 :
ntt_name
ntt_lookup1
ntt_lookup2
Requirement : 要求 :
Read the value of ntt_lookup1 and ntt_lookup2 and get the name (not the id) and concatenate them and populate it on the name field (Primary Attribute). 读取ntt_lookup1和ntt_lookup2的值并获取名称(而不是id)并将它们连接起来并在名称字段(主要属性)上填充它。
I upload this as a Web Resource, associate it with the Form MyForm and add it to the onsave event. 我将其作为Web资源上传,将其与Form MyForm关联,并将其添加到onsave事件中。
I get the following error. 我收到以下错误。
Question : What am I doing wrong? 问题 :我做错了什么?
What I have done so far : 到目前为止我做了什么 :
Code : 代码 :
if (typeof(CRMDynamics2011) == "undefined")
{ CRMDynamics2011 = {}; }
CRMDynamics2011.MyForm = {
FormSave: function() {
alert("Within Function FormSave");
var lookup1 = Xrm.Page.getAttribute("ntt_lookup1").getValue();
var lookup2 = Xrm.Page.getAttribute("ntt_lookup2").getValue();
if (lookup1 != null && lookup1[0] && lookup1[0].name != null) {
alert("lookup1 is NOT NULL");
var value1 = lookup1[0].name;
}
if (lookup2 != null && lookup2[0] && lookup2[0].name != null) {
alert("lookup2 is NOT NULL");
var value2 = lookup2[0].name;
}
var fieldName = Xrm.Page.getAttribute("ntt_name");
fieldName.setValue(value1 + ' - ' + value2);
}
};
As you are using namespacing, you must fully qualify the method you want to call. 在使用命名空间时,必须完全限定要调用的方法。
So in the form properties for CRM, for the OnSave event use 因此,在CRM的表单属性中,为OnSave事件使用
CRMDynamics2011.MyForm.FormSave();
CRM should then call your method when you click save. 然后,当您单击“保存”时,CRM应调用您的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.