When using SuiteScript 2.0, the old method nlapiGetLineItemValue is no longer available for referencing line values on a new, unsaved record before submitting.
Instead, we need to use Record.getSublistValue(options).
However, when attempting to use this method, it may return the error message "getSublistValue" is not defined in object, indicating that unsaved records do not have defined lines.
The same issue may apply to AfterSubmit.
So, is there a workaround or even a possibility to reference the line item value when creating a record?
Here is an example of how you can use the getSublistValue method within your script:
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));
// Perform an action using the referenced line item value
Please note that if you are working with SuiteScript 1.0, the nlapiGetLineItemValue method can be used instead.