how to set a line in a landed cost subrecord of it...
# ask-stanley-ai
m
how to set a line in a landed cost subrecord of item receipt with suitescript 2.1
c
AI generated answer (using internal Slack threads):
To set a line in a landed cost subrecord of an item receipt with SuiteScript 2.1, you can use the
record.load
method to load the item receipt record. Then, use the
hasSublistSubrecord
method to check if there is an existing landed cost subrecord. If there is, you can use the
getSublistSubrecord
method to get the existing landed cost subrecord. Finally, use the
setSublistValue
method to set the value of the landed cost category. Here is a sample code snippet:
Copy code
javascript
var item_receipt = record.load({
    type: 'itemreceipt',
    id: itemReceiptId
});

var existing_sublist = item_receipt.hasSublistSubrecord({
    sublistId: 'item',
    fieldId: 'landedcost',
    line: lineId
});

var existing_landed_cost = item_receipt.getSublistSubrecord({
    sublistId: 'item',
    fieldId: 'landedcost',
    line: lineId
});

existing_landed_cost.setSublistValue({
    sublistId: 'landedcostdata',
    fieldId: 'landedcostcategory',
    value: 1,
    line: lineId
});
Please note that this code works in both dynamic and standard modes. However, you need to ensure that your lines and field IDs are correct. ****** 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.847568035
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.82787776
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.812404156
Please provide your feedback on this answer.