tiger
04/14/2025, 10:07 AMCeligo AI
04/14/2025, 10:07 AMAI generated answer (using internal Slack threads):To update sublist fields in NetSuite, you cannot use
record.submitFields()
. This method is used to update a field without loading/saving the record, but it does not work for sublist fields.
Instead, you can use Record.setSublistValue()
or Record.setCurrentSublistValue()
if you are using dynamic mode. Here's an example of how you can use these methods:
javascript
var invoiceRecord = record.load({
type : 'invoice',
id : newRecordID,
isDynamic : true
});
var lineCount = invoiceRecord.getLineCount('item');
for( var i = 0; i < lineCount; i++ ){
var item = invoiceRecord.getSublistValue({
sublistId : 'item',
fieldId : 'item',
line : i
});
if (item !== '6177'){
var quantity = invoiceRecord.getSublistValue({
sublistId : 'item',
fieldId : 'quantity',
line : i
});
var item = invoiceRecord.getSublistValue({
sublistId : 'item',
fieldId : 'item',
line : i + 1
});
if(item === '6177'){
invoiceRecord.setSublistValue({
sublistId : 'item',
fieldId : 'quantity',
line : i + 1,
value : quantity
});
}
}
}
invoiceRecord.save();
In this example, we're loading an invoice record in dynamic mode, iterating over its line items, and updating the quantity of a specific item.
Remember, when you're using dynamic mode, you need to use dynamic mode methods when getting/setting sublist line values. These include selectLine()
, getCurrentSublistValue()
, setCurrentSublistValue()
, and commitLine()
.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
04/14/2025, 10:08 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.845004141
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.829107106
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.822454095
Celigo AI
04/14/2025, 10:08 AM