简体   繁体   English

无法为自定义字段Dynamics 365设置值

[英]Unable to set value to custom field Dynamics 365

Background 背景

  • I have created a custom field in Dynamics 365 named new_statecode . 我在Dynamics 365中创建了一个名为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="">

  • I have written a Java script to get the value entered by the user and set the value in the custom field. 我已经编写了Java脚本来获取用户输入的值,并在自定义字段中设置值。

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.

相关问题 将 email 上的“至”字段设置为动态 365 - Set "to" field on email form i dynamics 365 Dynamics365。字段值(javascript) - Dynamics 365. Field value (javascript) Dynamics 365 CRM 插件 - 无法在托管解决方案中设置两个选项字段 NULL - Dynamics 365 CRM Plugin - Unable to set two option field NULL in managed solution 如何在JavaScript中使用Base64String值设置Dynamics CRM / 365字段 - How to set a Dynamics CRM/365 field with Base64String value in JavaScript javascript Dynamics 365无法在刷新前保存我的字段 - javascript Dynamics 365 unable to save my field before refreshing 使用 JavaScript 为 CRM Dynamics 365 隐藏/删除选项设置值? - Hide/remove Option set value using JavaScript for CRM Dynamics 365? 使用Dynamics 365中的Javascript使用链接的实体将自定义筛选器添加到字段 - Add Custom Filter to a field using linked entities using Javascript in Dynamics 365 Dynamics 365 自定义 javascript 设置字段级别通知后不会执行保存 - Dynamics 365 custom javascript won't execute save after setting field level notification 在 Dynamics 365 XRM Web API 中创建记录时无法设置多选选项字段 - Cannot set multi-select option field when creating record in Dynamics 365 XRM Web API 将 Dynamics 365 地址字段转换为下拉列表 - Turn Dynamics 365 address field into dropdown list
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM