0
votes

I'm trying to create a restlet that can create a bin transfer. My code is almost complete, I can create line item fields also.

The only thing that I can't do is to fill up the inventory detail because I don't know the fields in Subrecords. How can inpect the field id in the sub records line items columns?

define([ 'N/record', 'N/search'], function(r, s) {
function onSendRequst(context) 
{

    var rec = r.create({
        type: context.recordtype,
        isDynamic: true
    });

    rec.setValue( 'location', context.from_location_id );
    rec.setValue( 'transferlocation', context.to_location_id );
    rec.setValue( 'memo', context.memo );     

    for( var i = 0; i < context.inventory.length; i++)
    {
        var inv = context.inventory;

        // Create sublist Record
        rec.selectNewLine({
            sublistId: 'inventory',
            line: i+1
        });

        rec.setCurrentSublistValue({
            sublistId: 'inventory',
            fieldId: 'item',
            value: inv[i].item_ndc
        });
        rec.setCurrentSublistValue({
            sublistId: 'inventory',
            fieldId: 'adjustqtyby',
            value: inv[i].qty
        });

        rec.commitLine({
            sublistId: 'inventory'
        });


        // **CREATE A SUB RECORD**

        var itemInventorySubrecord = r.getSublistSubrecord({
            sublistId: 'item',
            fieldId: 'inventorydetail',
            line: x
        });
    }
    var recordId = rec.save({
        enableSourcing: true,
        ignoreMandatoryFields: true
    });
    return recordId;
}

return {
    post: onSendRequst
} 
});
1

1 Answers

0
votes

You can find the field IDs for inventory detail under the Inventory Detail entry in the Records Browser. Subrecords are available in the SuiteScript Records Browser just like regular records.