简体   繁体   中英

NetSuite SuiteScript 2.0 fieldChanged - Get Cause For Field Change

I have a 2.0 SuiteScript ClientScript that changes the value in a field based on a change to the value in another field, running off the fieldChanged event.

So, if the value in field XYZ is changed, I check its new value and set the value in field ABC accordingly.

I also have another field, DEF. If it's value is changed, I check its new value and set the value in fields XYZ and ABC accordingly. Setting the value of fields XYZ and ABC, of course, fires the fieldChanged even for field XYZ, which changes the value of field ABC. But I don't want that to happen in this instance - I set the value of field ABC based on DEF, and don't want it reset based on XYZ.

So basically, if field XYZ is changed by user action, I want to set the value of the field ABC. But if field XYZ is changed by this script, I do not want to set the value of the field ABC.

I was hoping there was something in the currentRecord object that said the origin of the change, but there's not. Is there any way I can determine how the change to field XYZ happened? Is there any way I can prevent the change to field XYZ prompting the change in the field ABC if XYZ was, itself, changed because of the change to DEF, rather than by user action?

When you set the value of a field with a script, you can also tell it to not trigger another field changed event.

customer.setValue({
    fieldId: 'custbody_some_field',
    value: someValue,
    ignoreFieldChange: true
});

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