Hi Guys, anyone know how to add package sublist to...
# suitescript
m
Hi Guys, anyone know how to add package sublist to the Itemfulfillment while creating ItemFulFillment using
record.transform
b
what have you tried
m
Copy code
var fulfillment = record.transform({
                fromType: record.Type.SALES_ORDER,
                fromId: transaction.id,
                toType: record.Type.ITEM_FULFILLMENT
            });
fulfillment.setValue({ fieldId: 'status', value: 'ItemShip: C' });
            // add packages here
            for (var i = 0; i < lineItems.length; i++) {
                fulfillment.selectNewLine({ sublistId: 'package' });

                fulfillment.setCurrentSublistValue({ sublistId: 'package', fieldId: 'packageweight', value: lineItems[i]['LineDetails'][0].NetWeight, forceSyncSourcing: true });
                fulfillment.setCurrentSublistValue({ sublistId: 'package', fieldId: 'packagedescr', value: lineItems[i].CustomerPartNumber, forceSyncSourcing: true });
                fulfillment.setCurrentSublistValue({ sublistId: 'package', fieldId: 'packagetrackingnumber', value: lineItems[i]['LineDetails'][0].TrackingNumber, forceSyncSourcing: true });
                // Commit Line
                fulfillment.commitLine({ sublistId: 'package' });
            }
b
that sublist code only works on dynamic mode
m
So, Is there any way I can add a package sublist?
b
the same way you would a normal sublist
m
Copy code
rec.insertLine({"sublistId": "package", "line": 0});
    rec.setSublistValue({"sublistId": "package", "fieldId": "itemReceive", "value": true, "line": 0});
    rec.setSublistValue({"sublistId": "package", "fieldId": "quantity", "value": 5, "line": 0});
b
most of the time the insertLine isnt what you actually want
but yes, that is the normal way to set a standard records sublist related fields
1
k
@MUHAMMAD MUBUSHER ASLAM