Hi -
I'm not that new to NS, but have never done any scripting. I would like to total a custom field I created that lives on the item line in an order or invoice. I called it "custcolitemtest1". It's a currency type field.
I'd like to total all the values in "custcolitemtest1" into the custom Transaction Body field I created "custbodytesttotal1".
I've read loads of documentation on scripting, and found an old post that seemed it would do what I wanted, but I'm lost. I can code in SQL, but have never done java. I'm usually pretty good at figuring these types of things out, (as long as they're this simple) espeically if I get something to copy.
So I found a script that seemed to do what I want, but I cannot get it to work. I want the script to run - and calculate/update the total in custbodytesttotal" - whenver anyone enters a value, or changes a value in "custcolItemtest1" - my custom Item field.
Code I found:
function onSaveFulfillment() {
for( var i = 1; i <= nlapiGetLineItemCount('item'); i++) {
var quantityCartonLine = nlapiGetLineItemValue('item', 'custcol_yourColumnFieldID', i ); (my field would be custcolItemtest1)
if( isNaN(quantityCartonLine) || quantityCartonLine == null || quantityCartonLine == '' ) {
quantityCartonLine = 0;
}
quantityTotal = quantityCartonLine++
}
nlapiSetFieldValue('custbody_yourTotalFieldID', quantityTotal, false, false);
return true;
} (my total field would be "custbodytesttotal1")
Can anyone help? I am trying in a Sandbox, but so far, so bad!
Thanks -
sara