Reputation: 127
I am making a usereventcript that computes for the rate using subfields from the sales order item list. trying to save and deploy the script launches an error 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,
};
});
Upvotes: 0
Views: 3367
Reputation: 2069
Your code is not syntactically valid. Please replace below code
var newRate = context.newRecord.setValue({
fieldId: 'rate'
value: ('rate', rate_)
});
with
var newRate = context.newRecord.setValue({
fieldId: 'rate',
value: ('rate', rate_)
});
You can try validating your code with JS syntax validator esprima. Although alot of IDE's now support validation.
Upvotes: 2