【问题标题】:SuiteScript deploying script Fail to evaluate scriptSuiteScript 部署脚本 无法评估脚本
【发布时间】:2019-01-17 06:06:48
【问题描述】:

我正在制作一个 usereventcript,它使用销售订单项目列表中的子字段计算费率。尝试保存和部署脚本会启动错误 无法评估脚本:{"type":"error.SuiteScriptModuleLoaderError","name":"UNEXPECTED_ERROR","message":"missing } after property list (SS_SCRIPT_FOR_METADATA#32)" "栈":[]}

/**
*@NApiVersion 2.x
*@NScriptType UserEventScript
*/
define(
[
    'N/record'
],
function (record) {

    /**
    * @param {UserEventContext.beforeSubmit} context
    */
     function beforeSubmit(context) {
        //get taxcode
        var taxcode = context.newRecord.getValue({
            fieldId: 'taxcode'
          });
        if(taxcode !== 0 || taxcode !== 4){
            // Gets the Total Amount
            var amount = context.getValue.getValue({
              fieldId: "amount"
            });

        // Gets the quantity of an item selected
        var quantity = context.newRecord.getValue({
        fieldId: 'quantity'
        });            
        var rate_ = amount/quantity;
        var newRate = context.newRecord.setValue({
            fieldId : 'rate'
            value : ('rate',rate_)
            });
        }
    }


    return {

        // beforeSubmit: beforeSubmit,

    };
});

【问题讨论】:

    标签: netsuite suitescript suitescript2.0


    【解决方案1】:

    您的代码在语法上无效。请替换下面的代码

    var newRate = context.newRecord.setValue({
      fieldId: 'rate'
      value: ('rate', rate_)
    });
    

    var newRate = context.newRecord.setValue({
      fieldId: 'rate',
      value: ('rate', rate_)
    });
    

    您可以尝试使用 JS 语法验证器 esprima 来验证您的代码。虽然现在很多 IDE 都支持验证。

    【讨论】:

    • 现在它只是说“SuiteScript 2.0 入口点脚本必须实现一种脚本类型函数。”但我猜它是我的代码对吗?
    • 对,如果查看您的代码,beforeSubmit 会在底部注释。取消注释它应该可以工作
    • 这看起来也是错误的: // 获取总金额 var amount = context.getValue.getValue({ fieldId: "amount" });应该是 // 获取总金额 var amount = context.newRecord.getValue({ fieldId: "amount" });
    • @RustyShackles 是的,但这可能已经导致错误。
    猜你喜欢
    • 2013-10-05
    • 2022-11-03
    • 1970-01-01
    • 2020-03-11
    • 2020-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多