Hi,
I am fairly new to Netsuite, and very new to SuiteScript, but do have some experience with Java.
I am trying to get the Total Weight of the items on an Invoice to reflect in a custom body field. (that I can reference on a custom invoice pdf)
I have found this SuiteAnswer: 37168
"Calculate Total Weight"
The script that it provides is throwing an error:
Fail to evaluate script: {"type":"error.SuiteScriptModuleLoaderError","name":"UNEXPECTED_ERROR","message":"ReferenceError: \"objRecord\" is not defined. (SS_SCRIPT_FOR_METADATA#6)","stack":[]}
When I research this, it appears that SuiteScripts may now require a define() function. Which I am not sure exactly how the syntax should be applied to make it work.
Here is my script code currently.
/**
*@NApiVersion 2.x
*@NScriptType ClientScript
*/
var lines = objRecord.getLineCount({sublistId: 'item'});
var totalWeight = 0 ;
for(var i=1; i< lines+1 ; i++){
var weight = record.getSublistValue({sublistId: 'item',fieldId: 'custcol_weight',line: i});
var quantity = record.getSublistValue({sublistId: 'item',fieldId: 'quantity',line: i});
var weightTimesQuantity = weight * quantity;
totalWeight = totalWeight + weightTimesQuantity;
};
objRecord.setValue({fieldId: 'custbody_items_total_weight',value: totalWeight});
Can you please help me correct this script so that I can get it installed and get this working...
Thanks
J