Why in a Workflow Action Script, I get an error sa...
# ask-stanley-ai
a
Why in a Workflow Action Script, I get an error saying context.newRecord.setSublistValue function doesn't exist? context.newRecord is a record.Record object, and those have setSublistValue function.
c
AI generated answer (using internal Slack threads):
****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ****** The error you're encountering is likely due to the fact that you're trying to use the
setSublistValue
function on a dynamic record. In NetSuite, there are two types of records: standard and dynamic. The
setSublistValue
function is only available for standard records. For dynamic records, you should use the
selectLine
,
setCurrentSublistValue
, and
commitLine
functions instead. Here's an example of how you can do this:
Copy code
javascript
var item_record = record.load({
    type: record.Type.INVENTORY_ITEM,
    id: item_id,
    isDynamic: true,
});

item_record.selectLine({sublistId: 'price1', line: 10})
item_record.setCurrentSublistValue({
    sublistId: 'price1',
    fieldId: 'price_1_',
    value: display_price
});
item_record.commitLine({sublistId: 'price1'});
If you want to use
setSublistValue
, you need to load the record as a standard record by setting
isDynamic
to `false`:
Copy code
javascript
var item_record = record.load({
    type: record.Type.INVENTORY_ITEM,
    id: item_id,
    isDynamic: false,
});

item_record.setSublistValue({
    sublistId: 'price1',
    fieldId: 'price_1_',
    line: 10,
    value: display_price
});
Please note that working with dynamic and standard records have different implications and you should choose the one that best fits your use case. For more information, you can refer to the NetSuite Help Center or SuiteAnswers.
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.87323
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.868652344
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.866272
Please provide your feedback on this answer.
Thank you for your feedback