This relates to some older questions on SuiteScript 1.0. I've got a 2.0 script that has to be 2.0, so I can't use the old nlapiGetLineItemValue
- it has to be Record.getSublistValue(options)
. But I need it to get the line value on a new, unsaved record BeforeSubmit
.
It keeps returning "getSublistValue" is not defined in object, and checking NetSuite Field Explorer confirms that the unsaved record has no defined lines.
The same applies to AfterSubmit
.
So is there any work around, or is it even possible, to reference the line item value when the record is being created?
ADDING SOME CODE, WHERE THE QUESTION APPLIES:
var recNew = context.newRecord
var ItemID = recNew.getSublistValue({
sublistId: 'items',
fieldId: 'itemid',
});
var listIDs = ["6646", "17745", "17945", "21349"];
var a_filters = [];
a_filters.push(new nlobjSearchFilter(ItemID, null, 'anyof', listIDs));
{
// an action
}
getSublistValue requires you to pass the line number.
var recNew = context.newRecord
for (var x =0; x< recNew.getLineCount({sublistId:'item'}); x++) {
var ItemID = recNew.getSublistValue({ sublistId: 'item', fieldId: 'item', line: x });
// DO STUFF
}