简体   繁体   中英

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

I want to set default values on account form by JavaScript. I use OData to read these defaults and there is some logic.

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. Can I prevent this? I tried to work with setSubmitMode function, didn't work out.

Is there another way to set values in JScript without making it dirty?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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