Nour
10/06/2025, 12:25 PMCeligo AI
10/06/2025, 12:25 PMAI generated answer (using internal Slack threads):It seems like you're trying to insert a new line into a sales order and then retrieve the inventory detail subrecord of the newly inserted line. However, you're encountering an issue where the subrecord retrieved is from the existing line at that index, not the new one. This issue might be due to the way NetSuite handles line insertion. When you insert a line, NetSuite shifts the existing lines down, but it doesn't immediately update the line numbers. This means that when you try to retrieve the subrecord immediately after inserting the line, you're actually getting the subrecord of the line that was originally at that index. To overcome this, you could try the following approach: 1. After inserting the new line, commit the line using the
commitLine
function. This should update the line numbers.
2. Then, retrieve the subrecord of the new line. At this point, the line numbers should have been updated, so you should be able to retrieve the correct subrecord.
Here's a sample code snippet based on the code you provided:
javascript
// Insert the new line
currentRec.insertLine({
sublistId: "inventory",
line: desiredLineIndex
});
// Set the values for the new line
currentRec.selectLine({
sublistId: "inventory",
line: desiredLineIndex
});
currentRec.setCurrentSublistValue({
sublistId: "inventory",
fieldId: "item",
value: newItemId
});
// ... set other field values ...
// Commit the new line
currentRec.commitLine({
sublistId: "inventory"
});
// Now, retrieve the subrecord of the new line
var subrecord = currentRec.getSublistSubrecord({
sublistId: "inventory",
fieldId: "inventorydetail",
line: desiredLineIndex
});
Remember to replace desiredLineIndex
and newItemId
with the actual line index and item ID you want to use.
******
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
10/06/2025, 12:25 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.875732422
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.863098145
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.860534668
Celigo AI
10/06/2025, 12:25 PM