Bruce Backman
06/06/2025, 3:11 PMCeligo AI
06/06/2025, 3:12 PMAI generated answer (using internal Slack threads):Here is a SuiteScript 2.1 snippet that will remove the item with lineuniquekey=54321 from the salesorder with internal id 12345:
javascript
require(['N/record'], function(record) {
var salesOrderId = 12345;
var salesOrder = record.load({
type: record.Type.SALES_ORDER,
id: salesOrderId,
isDynamic: true
});
var numLines = salesOrder.getLineCount({ sublistId: 'item' });
for (var i = 0; i < numLines; i++) {
var lineUniqueKey = salesOrder.getSublistValue({
sublistId: 'item',
fieldId: 'lineuniquekey',
line: i
});
if (lineUniqueKey == 54321) {
salesOrder.removeLine({
sublistId: 'item',
line: i
});
break;
}
}
var recordId = salesOrder.save();
log.debug("Sales Order updated", "Sales Order id: " + recordId);
});
This script first loads the sales order record with the given internal id. It then iterates over each line in the 'item' sublist, checking the 'lineuniquekey' field. If it finds a line with the 'lineuniquekey' equal to 54321, it removes that line and breaks out of the loop. Finally, it saves the sales order record and logs the id of the updated record.
******
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
06/06/2025, 3:13 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.811809063
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.809469938
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.806186378
Celigo AI
06/06/2025, 3:13 PM