SuiteScript 部署脚本 无法评估脚本
SuiteScript deploying script Fail to evaluate script
我正在制作一个用户事件脚本,它使用销售订单项目列表中的子字段来计算费率。尝试保存和部署脚本会启动错误 无法评估脚本:{"type":"error.SuiteScriptModuleLoaderError","name":"UNEXPECTED_ERROR","message":"missing } after property list (SS_SCRIPT_FOR_METADATA#32)","stack":[]}
/**
*@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,
};
});
您的代码在语法上无效。请替换下面的代码
var newRate = context.newRecord.setValue({
fieldId: 'rate'
value: ('rate', rate_)
});
与
var newRate = context.newRecord.setValue({
fieldId: 'rate',
value: ('rate', rate_)
});
您可以尝试使用 JS 语法验证器 esprima 来验证您的代码。虽然很多 IDE 现在都支持验证。
我正在制作一个用户事件脚本,它使用销售订单项目列表中的子字段来计算费率。尝试保存和部署脚本会启动错误 无法评估脚本:{"type":"error.SuiteScriptModuleLoaderError","name":"UNEXPECTED_ERROR","message":"missing } after property list (SS_SCRIPT_FOR_METADATA#32)","stack":[]}
/**
*@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,
};
});
您的代码在语法上无效。请替换下面的代码
var newRate = context.newRecord.setValue({
fieldId: 'rate'
value: ('rate', rate_)
});
与
var newRate = context.newRecord.setValue({
fieldId: 'rate',
value: ('rate', rate_)
});
您可以尝试使用 JS 语法验证器 esprima 来验证您的代码。虽然很多 IDE 现在都支持验证。