Client Script adding item is not working

Hi All.

I’m trying to create line items using Client script when the page loads.

But somehow the item is added but get removed immediately after that.

Just quantity column left

for(var i=0; i<oldItemsCnt; i++){
    let oldItemAmount = oldRecord.getSublistValue('item', 'amount', i);
    let oldItem = oldRecord.getSublistValue('item', 'item', i);
    // currentRecord.setSublistValue({sublistId:'item', fieldId:'amount', line:i, value:oldItemAmount});
    var lineNum = currentRecord.selectLine({
        sublistId: 'item',
        line: i
    });
    currentRecord.setCurrentSublistValue({
        sublistId: 'item',
        fieldId: 'amount',
        value: oldItemAmount
    });
    currentRecord.setCurrentSublistValue({
        sublistId: 'item',
        fieldId: 'item',
        value: oldItem
    });
    console.log('oldItem', oldItem);
    currentRecord.commitLine({
        sublistId: 'item'
    });
}
Any help would be appreciated
Rookie Asked on July 31, 2022 in SuiteCloud.
Add Comment