How can you modify an item receipt's item lines vi...
# suitescript
j
How can you modify an item receipt's item lines via script without them deleting? I have a client script (I know I know) from a Suitelet that is supposed to open the item receipt and update specific line item fields. For some reason, it just deletes the lines. Ignore the naming convention, this was originally only for Purchase Orders but I expanded it to work on all transactions. Item Receipts are giving me trouble. If relevant, we use bins.
Copy code
function setWorkOrders(creationList, poId, poType) {
            if (creationList.length === 0) return;
            var poRecord = record.load({
                type: poType,
                id: poId
            });

            for (i = 0; i < creationList.length; i++) {
                 console.log({
                    title: "Record " + i,
                    details: "Component: " + creationList[i].componentId + " | Work Order: " + creationList[i].createdRecord
                }); 
                var lineNumber = poRecord.findSublistLineWithValue({
                    sublistId: 'item',
                    fieldId: 'item',
                    value: creationList[i].componentId
                });
                
                console.log({
                    title: "Line Number",
                    details: lineNumber
                }); 
                if (lineNumber >= 0) {
                    poRecord.setSublistValue({
                        sublistId: 'item',
                        fieldId: 'custcol_related_work_order',
                        line: lineNumber,
                        value: creationList[i].createdRecord
                    });
                }
            }
            poRecord.save();
            return;
        }