I set the landedcostamount8 in the landedcostdata ...
# ask-stanley-ai
a
I set the landedcostamount8 in the landedcostdata sublist of a Landed Cost subrecord on an Item line of an Item Receipt record in SuiteScript 2.1 user event script beforeSubmit function, but it hasn't changed to my new value when I load the Item Receipt again.
c
AI generated answer (using internal Slack threads):
It seems like you're trying to set the
landedcostamount8
field in the
landedcostdata
sublist of a Landed Cost subrecord on an Item line of an Item Receipt record in SuiteScript 2.1 user event script beforeSubmit function, but it's not reflecting the changes when you load the Item Receipt again. Based on the conversations, it appears that you might be missing a step or two. Here's a general approach to handle this: 1. Load the Item Receipt record using
record.load()
. 2. Check if the Item Receipt has a Landed Cost subrecord using
record.hasSublistSubrecord()
. 3. If it does, get the Landed Cost subrecord using
record.getSublistSubrecord()
. 4. Set the
landedcostamount8
field value in the
landedcostdata
sublist of the Landed Cost subrecord using
record.setSublistValue()
. 5. Save the changes using
record.save()
. Here's 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
});

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

    existing_landed_cost.setSublistValue({
        sublistId: 'landedcostdata',
        fieldId: 'landedcostamount8',
        value: newValue,
        line: lineId
    });

    item_receipt.save();
}
Please replace
itemReceiptId
,
lineId
, and
newValue
with your actual values. Remember, this operation should be performed in dynamic mode. If you're not in dynamic mode, you might need to adjust your lines and field IDs correctly. ****** 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.883972228
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.859436154
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.85772717
Please provide your feedback on this answer.