SunShine
02/05/2025, 8:32 PMCeligo AI
02/05/2025, 8:32 PMAI generated answer (using internal Slack threads):To get each item's parent Item in a sales order using SuiteScript 2.0, you can use the
getCurrentSublistValue
method on the sales order record. Here is a sample code snippet:
javascript
var salesOrderRecord = record.load({
type: record.Type.SALES_ORDER,
id: 'your_sales_order_id'
});
var numLines = salesOrderRecord.getLineCount({
sublistId: 'item'
});
for (var i = 0; i < numLines; i++) {
var itemId = salesOrderRecord.getSublistValue({
sublistId: 'item',
fieldId: 'item',
line: i
});
var itemRecord = record.load({
type: record.Type.INVENTORY_ITEM, // or whatever the item type is
id: itemId
});
var parentItemId = itemRecord.getValue({
fieldId: 'parent'
});
// Now you have the parent item id, you can load the parent item record if needed
}
This script loads the sales order record, iterates over the line items, and for each line item, it loads the item record and gets the parent item id.
******
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
02/05/2025, 8:32 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.821822286
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.820071638
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.818463087
Celigo AI
02/05/2025, 8:32 PM