简体   繁体   English

NetSuite SuiteScript 2.0 fieldChanged - 获取字段更改的原因

[英]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.我有一个 2.0 SuiteScript ClientScript,它根据对另一个字段中值的更改来更改字段中的值,运行 fieldChanged 事件。

So, if the value in field XYZ is changed, I check its new value and set the value in field ABC accordingly.因此,如果字段 XYZ 中的值发生更改,我会检查其新值并相应地设置字段 ABC 中的值。

I also have another field, DEF.我还有另一个领域,DEF。 If it's value is changed, I check its new value and set the value in fields XYZ and ABC accordingly.如果它的值改变了,我检查它的新值并相应地在字段 XYZ 和 ABC 中设置值。 Setting the value of fields XYZ and ABC, of course, fires the fieldChanged even for field XYZ, which changes the value of field ABC.当然,设置字段 XYZ 和 ABC 的值会触发字段 XYZ 的 fieldChanged,这会更改字段 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.但我不希望在这种情况下发生这种情况 - 我根据 DEF 设置字段 ABC 的值,并且不希望它根据 XYZ 重置。

So basically, if field XYZ is changed by user action, I want to set the value of the field ABC.所以基本上,如果用户操作更改了字段 XYZ,我想设置字段 ABC 的值。 But if field XYZ is changed by this script, I do not want to set the value of the field ABC.但是,如果此脚本更改了字段 XYZ,我不想设置字段 ABC 的值。

I was hoping there was something in the currentRecord object that said the origin of the change, but there's not.我希望 currentRecord object 中有说明更改来源的内容,但没有。 Is there any way I can determine how the change to field XYZ happened?有什么方法可以确定字段 XYZ 的更改是如何发生的? 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?如果 XYZ 本身由于更改为 DEF 而不是通过用户操作而更改,有什么方法可以防止更改字段 XYZ 提示字段 ABC 中的更改?

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
});

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

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