Hi,
I am executing this code below by way of a custom workflow action and for whatever reason the total of the calculation is showing as a string and not a number. i.e. the error I get is: "You have entered an Invalid Field Value 012150.00200.0012350.00150.00 for the following field: custbody_gross_profit". It should in fact be the sum of those values.
Its obviously concatenating the numbers rather than adding them? Am I being slow?
There is a more complex calc to follow but in the meantime this should just add up the amount field on a transaction... shouldn't it?
function Calc()
{
// Define variables
var n_icount = nlapiGetLineItemCount('item');
var GrossProfit = 0;
var Amount = 0;
// Loop through line items
for (var i = 1; i <= n_icount; i++)
{
// Set focus on line
nlapiSelectLineItem('item',i);
Amount = nlapiGetCurrentLineItemValue('item', 'amount');
if (Amount != 0)
{
GrossProfit = GrossProfit + Amount;
}
}
nlapiSetFieldValue('custbody_gross_profit', GrossProfit, false);
}
Appreciate any help. Thanks very much.
Cheers,