Netsuite字段已更改值

Netsuite字段已更改值,netsuite,suitescript,Netsuite,Suitescript,当一个字段值被脚本更改时,我如何检测?实际上,我们有一个按钮,可以更新发票中的字段值(我无法编辑此脚本) /** * @NApiVersion 2.x * @NScriptType ClientScript * @Autor ***** * @NModuleScope Public * @Company ****** * @NModuleScope Public * */ define([ 'N/error', 'N/record', 'N/currentRecord', 'N/

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

/**
 * @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/需要运行时模块:

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

N/需要运行时模块:

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

这是我尝试在使用SuiteScript2.0提交后在SalesOrder上使用的解决方案,但是它失败了,出现以下错误:

  • org.mozilla.javascript.EcmaError:TypeError:无法从未定义的
  • org.mozilla.javascript.EcmaError:TypeError:无法从未定义的
  • 以下是失败的代码:

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

    这是我尝试在使用SuiteScript2.0提交后在SalesOrder上使用的解决方案,但是它失败了,出现以下错误:

  • org.mozilla.javascript.EcmaError:TypeError:无法从未定义的
  • org.mozilla.javascript.EcmaError:TypeError:无法从未定义的
  • 以下是失败的代码:

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

    请详细说明你的问题。据我所知,该字段在用户界面之外发生更改时。您需要确定此字段是否通过webservice或任何其他脚本更新。这是正确的。请详细说明您的问题。据我所知,该字段在用户界面之外发生更改时。您需要确定此字段是否通过webservice或任何其他脚本更新,这是正确的。*@NScriptType UserEventScript*/define([“N/runtime”、'N/record'、'N/file'],function(runtime、record、file){var exports={};function afterSubmit(scriptContext){yourfunctiontxxxxxx(scriptContext);}函数notifySupervisor(scriptContext){if(runtime.executionContext!==runtime.ContextType.USEREVENT){///您的代码在这里}}exports.afterSubmit=afterSubmit;return exports;});*@NScriptType UserEventScript*/define([“N/runtime”,“N/record”,“N/file']),函数(runtime,record,file){var exports={};函数submit后(scriptContext){yourfunctiontxxxxxx(scriptContext);}函数notifySupervisor(scriptContext){if(runtime.executionContext!==runtime.ContextType.USEREVENT){///您的代码在这里}}exports.afterSubmit=afterSubmit;return exports;});