I'm writing a SuiteScript 2.0 Scheduled Script to copy data from some (but not all) Items in a Sales Order over to a new Custom record type.
The trouble is with the "rate" column on Sales Order : Item sublist.
If I use:
var lineCount = salesOrder.getLineCount({ sublistId: 'item' });
for (var i = 0; i < lineCount; i++){
var itemRate = salesOrder.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i });
log.debug("itemRate", itemRate);
log.debug("item rate text", salesOrder.getSublistText({ sublistId: 'item', fieldId: 'rate', line: i }));
}
then I get "-100" in the first DEBUG log,
and "-100.00" in the second.
This would be fine if the Item : Rate was set to -100, but it's set to -100.0%
Negative one hundred percent can mean a very different amount than negative one hundred dollars.
Nothing I've tried seems to be able to pull back the percent sign,
except if I run nlapiGetFieldValue from the browser console.
I can't exactly run the browser console in a scheduled script.
I've tried:
- Creating a non-stored formula field that grabs {rate} -- still comes back as "-100".
- Loading the Sales Order in both dynamic and non-dynamic mode.
- Saved Search -- this doesn't work because there is no "rate" search column in the salesorder.item search columns. Could it be found under another name?
I need it to get the value that was set on the salesorder.item sublist, because the users are allowed to overwrite the regular Rate on this Discount item, to suit their needs.
How do I find out if it's a percent discount or a dollar discount, in a scheduled script?