简体   繁体   English

Dynamics CRM 2015:在JScript中设置默认值而不会使表单变脏

[英]Dynamics CRM 2015: Set default value in JScript without making form dirty

I want to set default values on account form by JavaScript. 我想通过JavaScript在帐户表单上设置默认值。 I use OData to read these defaults and there is some logic. 我使用OData读取这些默认值,并且有一些逻辑。

I use standard way to set these values: 我使用标准方法来设置这些值:

Xrm.Page.getAttribute("myField").setValue(defaultValue);

Now this field is marked dirty and auto save will save it after 30 seconds. 现在,该字段被标记为脏,并且自动保存将在30秒后将其保存。 Can I prevent this? 我可以预防吗? I tried to work with setSubmitMode function, didn't work out. 我试图使用setSubmitMode函数,但没有解决。

Is there another way to set values in JScript without making it dirty? 还有另一种在JScript中设置值而又不会使其变脏的方法吗?

Make sure to set setSubmitMode('never') for this field on the form's onLoad() event, also then add a function for this fields' onChange() that then changes the setSubmitMode('always') again. 确保在表单的onLoad()事件上为此field设置setSubmitMode('never') ,然后为该字段的onChange()添加一个函数,然后再次更改setSubmitMode('always')

Theoretically this field wont then get submitted by MSCRM after doing the setValue(), but a new event triggering the onChange() event like the user manually changing it, will instruct MSCRM to change this and submit the field. 从理论上讲,此字段在执行setValue()之后不会由MSCRM提交,但是触发onChange()事件的新事件(如用户手动更改它)将指示MSCRM更改此字段并提交该字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM