ericbirdsall
09/16/2021, 9:48 PMlet salesOrder = context.newRecord;
let itemName = salesOrder.getSublistValue({
sublistId: 'item',
fieldId: 'item_display',
line: 0
}); // Returns Undefined
Mike Robbins
09/16/2021, 10:06 PMgetSublistText()
on the item
field to get the item name.
let itemName = salesOrder.getSublistText({
sublistId: 'item',
fieldId: 'item',
line: 0
});
Tyn Guardian
09/16/2021, 10:43 PMericbirdsall
09/16/2021, 11:22 PM"Invalid API usage. You must use getSublistValue to return the value set with setSublistValue"
Which didn't feel right, as I'm not setting any values in the sublist via script. But that's the error I. was gettingDominic B
09/17/2021, 11:32 AMMike Robbins
09/17/2021, 2:50 PM.setSublistValue
on that field before calling getSublistText
, you’ll get that message. Might be time for a call to search.lookupFields
or search.create
if you need to get the item name for all lines.Mike Robbins
09/17/2021, 2:52 PMgetSublistText
works by itself in afterSubmit for me, and I can duplicate your error message by setting a new value in that field with .setSublistValue
right before calling getSublistText
.ericbirdsall
09/17/2021, 5:05 PM