Aaron McCausland
05/22/2026, 2:46 PMCeligo AI
05/22/2026, 2:46 PMAI generated answer (using internal Slack threads):To remove all item groups from an Opportunity in SuiteScript, you would need to load the Opportunity record, iterate over the item lines, identify the item groups, and remove them. Here is a simplified example of how you might do this:
javascript
var record = require('N/record');
function removeItemGroupsFromOpportunity(opportunityId) {
var opportunity = record.load({
type: record.Type.OPPORTUNITY,
id: opportunityId,
isDynamic: true
});
var lineCount = opportunity.getLineCount({ sublistId: 'item' });
for (var i = lineCount - 1; i >= 0; i--) {
var itemType = opportunity.getSublistValue({
sublistId: 'item',
fieldId: 'itemtype',
line: i
});
if (itemType === 'Group') {
opportunity.removeLine({
sublistId: 'item',
line: i
});
}
}
opportunity.save();
}
This script loads the Opportunity record in dynamic mode, which allows you to interact with the record as if you were a user in the UI. It then gets the count of item lines on the Opportunity. It iterates over these lines in reverse order (to avoid index issues when removing lines). For each line, it checks the item type. If the item type is 'Group', which corresponds to an item group, it removes the line. Finally, it saves the Opportunity record.
Please note that this is a simplified example and may need to be adjusted to fit your specific needs. For example, you may need to handle error conditions, or you may need to adjust the logic for identifying item groups if your data is structured differently.
******
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
05/22/2026, 2:47 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.807251
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.804016113
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.800201297
Celigo AI
05/22/2026, 2:47 PM