What is the correct way to add the count detail pe...
# ask-stanley-ai
r
What is the correct way to add the count detail per line by script on the inventory count records?
c
AI generated answer (using internal Slack threads):
To add the count detail per line by script on the inventory count records, you can use SuiteScript's Subrecord API. Here is a general approach: 1. Select the line you want to work with using the
selectLine
method. 2. Get the inventory detail subrecord using the
getCurrentSublistSubrecord
method. 3. Use the
selectNewLine
method on the subrecord to create a new line in the inventory assignment sublist. 4. Set the quantity and inventory status using the
setCurrentSublistValue
method. 5. Commit the line using the
commitLine
method. Here is a sample code snippet that was provided in the conversations:
Copy code
javascript
fulfillment.selectLine({
    sublistId: 'item',
    line: j
});

fulfillment.setCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'itemreceive',
    value: true
});

var lineQty = fulfillment.getCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'quantity'
});

// Create the subrecord for that line.
var subrec = fulfillment.getCurrentSublistSubrecord({
    sublistId: 'item',
    fieldId: 'inventorydetail'
});

subrec.selectNewLine({
    sublistId: 'inventoryassignment'
});
subrec.setCurrentSublistValue({
    sublistId: 'inventoryassignment',
    fieldId: 'quantity',
    value: lineQty
});
subrec.setCurrentSublistValue({
    sublistId: 'inventoryassignment',
    fieldId: 'inventorystatus',
    value: 1
});

// Save the line in the subrecord's sublist.
subrec.commitLine({
    sublistId: 'inventoryassignment'
});

fulfillment.commitLine({sublistId: 'item'});
Please note that you need to replace
fulfillment
with your record instance and
j
with your line number. Also, the inventory status value may vary based on your setup. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.842444599
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.828631639
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.828011453
Please provide your feedback on this answer.