[英]Unable to set value to custom field Dynamics 365
Background 背景
new_statecode
. new_statecode
的自定义字段。 I am using an HTML webresource to get input from the user, that I later intend to pass to the custom field mentioned above. 我正在使用HTML网络资源来从用户那里获取输入,稍后我打算将其传递给上述自定义字段。
<input id="statecode" type="text" placeholder="">
This is the code for the script. 这是脚本的代码。
document.getElementById("submitButton").addEventListener("click", function (event) {
var strstatecode = document.getElementById("statecode").value;
window.parent.Xrm.Page.data.entity.attributes.get("new_statecode").setValue(strstatecode);
});
The problem 问题
This is the error I am getting in the console. 这是我在控制台中遇到的错误。
Unable to get property 'setValue' of undefined or null reference
I get a similar error when trying to use getValue
property too. 当尝试使用
getValue
属性时,我也会遇到类似的错误。
Apparently this is a very common issue but none of the other solutions work for me. 显然,这是一个非常普遍的问题,但是其他解决方案都不适合我。
What I have done so far 到目前为止我做了什么
I have looked here , here , here and at tons of other posts. 我在这里 , 这里 , 这里以及其他大量地方都看过。
I have checked the custom field name. 我已经检查了自定义字段名称。 There is no typo or spelling mistake.
没有错别字或拼写错误。
I have tried using window.parent.Xrm.Page.getAttribute("new_statecode").setValue(strstatecode);
我已经尝试使用
window.parent.Xrm.Page.getAttribute("new_statecode").setValue(strstatecode);
I have tried creating a new custom field and tried to set the value to it. 我尝试创建一个新的自定义字段,并尝试为其设置值。 That did not work either.
那也不起作用。 It gives the same error.
它给出了相同的错误。
Note1 : I think it is worth mentioning that the code I have posted has been edited and shortened to match the mcve standards of SO. 注意1 :我认为值得一提的是,我发布的代码已被编辑和缩短,以符合SO的mcve标准。 There are 6 other inputs (Street address, City, etc.) in my HTML webresource and I am successfully able to save the data to their respective fields in CRM.
我的HTML Web资源中还有其他6个输入(街道地址,城市等),并且我能够成功地将数据保存到CRM中它们各自的字段中。 The only difference is that those are not custom fields.
唯一的区别是,这些不是自定义字段。
Note2 : I am using Dynamics 365 Version 1612 (8.2.1.410). 注意2 :我使用的是Dynamics 365版本1612(8.2.1.410)。
How do I fix this problem? 我该如何解决这个问题? Is there anything else I should look at?
还有什么我应该看的吗? Maybe something I should have paid attention to while creating that custom field?
也许在创建该自定义字段时我应该注意的事情?
Forgive my lack of knowledge in CRM jargon. 原谅我缺乏CRM术语方面的知识。
An attribute/field needs to be present on a form to be reachable by Xrm.Page.getAttribute(attributeName)
. 属性/字段必须存在于
Xrm.Page.getAttribute(attributeName)
可以访问的Xrm.Page.getAttribute(attributeName)
。
However, it can be hidden, or placed in a hidden section or tab. 但是,它可以隐藏,也可以放置在隐藏的部分或选项卡中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.