Im trying to create a new script to update the sales order residential field to true when shipping carrier is FedEx Home Delivery (value is 2413).
Can you please help me identify the issue?
The script is
/**
- @NApiVersion 2 .1
- ],
columns:
[
search.createColumn({ name: "internalid", label: "Internal ID" }),
search.createColumn({ name: "tranid", label: "Document Number" }),
search.createColumn({ name: "shipmethod", label: "Shipping Method" })
]
});
var today = new Date();
today.setHours(0, 0, 0, 0);
var shipMethod = rec.getValue({
fieldId: 'shipmethod'
});
if (shipMethod === '2413')
rec.setValue({
fieldId: 'shipisresidential',
value: true
log.audit('Updated Sales Order', 'ID: ' + salesOrderId);
}
}
});
} catch (error) {
log.error('Error in execute:', error);
}function execute(context) {
try {
var salesorderSearchObj = search.create({
type: "salesorder",
settings: [{ "name": "consolidationtype", "value": "ACCTTYPE" }],
filters:
[
["type", "anyof", "SalesOrd"],
"AND",
["shipmethod"="2413", ""],
"AND",
["mainline", "is", "T"],}return {
execute: execute
};
});
I'm getting the following error when i try to upload the script
Fail to evaluate script: {"type":"error.SuiteScriptModuleLoaderError","name":"SyntaxError","message":"SyntaxError: /SuiteScripts/HG_SS_Hygea_Update_Residentail_for_fedex_home_delivery.js:16:25 Invalid left hand side for assignment\n [\"shipmethod\"=\"2413\", \"\"],\n ^\n/SuiteScripts/HG_SS_Hygea_Update_Residentail_for_fedex_home_delivery.js:20:20 Expected an operand but found ]\n ],\n ^\n/SuiteScripts/HG_SS_Hygea_Update_Residentail_for_fedex_home_delivery.js:27:13 Expected ; but found )\n });\n ^\n/SuiteScripts/HG_SS_Hygea_Update_Residentail_for_fedex_home_delivery.js:40:25 Expected comma but found ident\n\t log.audit('Updated Sales Order', 'ID: ' + salesOrderId);\n\t ^\n/SuiteScripts/HG_SS_Hygea_Update_Residentail_for_fedex_home_delivery.js:42:16 Expected , but found }\n }\n ^\n/SuiteScripts/HG_SS_Hygea_Update_Residentail_for_fedex_home_delivery.js:43:12 Expected eof but found }\n });\n ^\n [[\"shipmethod\"=\"2413\", \"\"],, ^, /SuiteScripts/HG_SS_Hygea_Update_Residentail_for_fedex_home_delivery.js:20:20 Expected an operand but found ]]","stack":["SyntaxError: /SuiteScripts/HG_SS_Hygea_Update_Residentail_for_fedex_home_delivery.js:16:25 Invalid left hand side for assignment"," [\"shipmethod\"=\"2413\", \"\"],"," ^","/SuiteScripts/HG_SS_Hygea_Update_Residentail_for_fedex_home_delivery.js:20:20 Expected an operand but found ]"," ],"," ^","/SuiteScripts/HG_SS_Hygea_Update_Residentail_for_fedex_home_delivery.js:27:13 Expected ; but found )"," });"," ^","/SuiteScripts/HG_SS_Hygea_Update_Residentail_for_fedex_home_delivery.js:40:25 Expected comma but found ident","\t log.audit('Updated Sales Order', 'ID: ' + salesOrderId);","\t ^","/SuiteScripts/HG_SS_Hygea_Update_Residentail_for_fedex_home_delivery.js:42:16 Expected , but found }"," }"," ^","/SuiteScripts/HG_SS_Hygea_Update_Residentail_for_fedex_home_delivery.js:43:12 Expected eof but found }"," });"," ^",""]}