Is it possible to update inventoryitem -> itemi...
# suitescript
d
Is it possible to update inventoryitem -> itemid field (Not the internal id)? I have written a suitescript mass update and attempted to set the field to a new value but it doesn’t work.
Copy code
/**
 * @NApiVersion 2.x
 * @NScriptType MassUpdateScript
 *
 */
define(['N/record'], function(record) {
    function each(params) {
        try {
            var rec = record.load({type: params.type, id: params.id});
            var new_itemId = rec.getValue('itemid')+" "+rec.getValue('displayname');
            rec.setValue({fieldId: "itemId", value: new_itemId});
            rec.setValue({fieldId: "displayname", value: ""});
            var id = rec.save();
        } catch (e) {
            log.error(funcName, e);
        }
    }
    return {
        each: each
    };
});
f
should the field id be itemId or itemid?
d
ok will try it
s
Also, itemid must be unique across items, so it will also fail if you try to write the value which is already present for another item.
d
it should work fine because it only works across existing items and since its concatenating the existing itemid (Already unique) with more data then it will remain unique
👍🏼 1
p
I would simply use a CSV update to make things simple.
d
Yeah a CSV would be a option if your not trying manage 1.5M products