Script used to add landed cost values to the item receipt lines.
let irRecord = record.load({
type: record.Type.ITEM_RECEIPT,
id: irRecId
});
let landedCostSubRecord = irRecord.getSublistSubrecord({
sublistId: 'item',
fieldId: 'landedcost',
line: irLineId
});
for (let j = 0; j < landedCostRecValues.length; j++) {
landedCostSubRecord.setSublistValue({
sublistId: 'landedcostdata',
fieldId: 'costcategory',
line: IRline,
value: landedCostRecValues[j].Cost_category
});
landedCostSubRecord.setSublistValue({
sublistId: 'landedcostdata',
fieldId: 'amount',
line: IRline,
value: amount
});
}
let recId = irRecord.save({
enableSourcing: true,
ignoreMandatoryFields: true
});