Netsuite 字段更改值

Netsuite Field Changed Value

我如何检测字段值何时被脚本更改,实际上我们有一个按钮并更新发票中的字段值(我无法编辑此脚本)

/**
 * @NApiVersion 2.x
 * @NScriptType ClientScript
 * @Autor *****
 * @NModuleScope Public
 * @Company ******
 * @NModuleScope Public
 *
*/

define([ 'N/error', 'N/record', 'N/currentRecord', 'N/log', 'N/runtime', 'N/url', 'N/https' ], function( error, record, currentRecord, log, runtime, url, https ) {

    var handler= {};
    handler.fieldChanged = function ( context ) {
        try{
            var currentRecord = context.currentRecord;
            var  field= context.fieldId
            if(campo='custbody_uuid')
            log.error( 'UUID', currentRecord.getValue({ fieldId: 'custbody_uuid' })) ;
                return;

        }catch(e)
        {
            log.error( 'ERROR_fieldChanged', JSON.stringify(e) );

        }
    }

    return handler;
});

我如何才能检测到字段何时更改但用户没有更改?

N/runtime 需要模块:

if (runtime.executionContext !== runtime.ContextType.USER_INTERFACE) {
    //your code here
}

这是我尝试在带有 SuiteScript 2.0 的 SalesOrder afterSubmit 上使用的解决方案,但它失败并出现以下错误:

  1. org.mozilla.javascript.EcmaError: 类型错误: 无法从未定义的
  2. 中读取 属性“USEREVENT”
  3. org.mozilla.javascript.EcmaError: TypeError: 无法从未定义的 属性 “executionContext”中读取

这是失败的代码:

define(["require", "exports", "N/record", "N/log", "N/https", "N/format", "N/runtime","N/ui","N/ui/serverWidget"],
function (require, exports, record, log, https, format, ui, runtime, context) {
if (runtime.executionContext === runtime.ContextType.USEREVENT) {
log.debug("runtime1");
} else {
log.debug("runtime2");
}