0

I'd like to convert some non inventory items into inventory items using suitescripts.

I know there is Convert to Inventory button on item detail page but I don't want to use this button. I have more than 5000+ non inventory items need to be changed into inventory so I don't want to repeat that 5000+ times.

So I'd like to build script to automate this action.

Looking forward to hearing from you soon. Best regard

1 Answers1

0

Well, since this is such a generic question, you can write some SuiteScript to do the work for you. But no matter what you do, you will have to do the field mapping yourself, especially if you have custom fields.

function transformItem(internalId) {
    var source = nlapiLoadRecord('noninventoryitem', internalId);
    var destination = nlapiCreateRecord('inventoryitem');
    var MAPPING = {
        'itemid': 'itemid',
        . . .
    };
    Object.keys(MAPPING).map(function (from_field) {
        var to_field = MAPPING[from_field];
        destination.setFieldValue(to_field, source.getFieldValue(from_field));
        return null;
    });
    nlapiSubmitRecord(destination);
}

You can see a list of available noninventory item fields here. Once you get the mapping, you can invoke this function for each of the products you want to transform.

2ps
  • 15,099
  • 2
  • 27
  • 47
  • 2
    This would not actually convert your items, it will just create a copy as an inventory item. Thus any previous transactions with the non-inventory items will not be tracked in the history of the new inventory items. – erictgrubaugh Mar 28 '16 at 13:53
  • To echo and add to Eric's point. Converting directly is impossible, since non-inventory items, and inventory items are different concepts in NetSuite. If you do create a new inventory item, you could also go back and edit (with a script) the previous transactions to create an inventory history. – TonyH Mar 28 '16 at 14:24