Happy Friday everyone! I have a couple of Inventor...
# suitescript
c
Happy Friday everyone! I have a couple of Inventory Number (Lot Number Record) records that have negative quantity on hand, which is obviously screwing up our inventory. Attempts at Inventory Adjustment fail because the lot numbers do not appear in the Inventory Detail for some reason. I looked into a mass update script, but it doesn't appear to support Inventory Numbers, so I'm trying adding a button and setting the quantity on hand in the Locations sublist to 0 in a client script. The script executes without error, but the quantity on hand is not changed. Is zeroing out the quantity on hand just not possible? The client script is as follows:
Copy code
define(["N/record", "N/url", "N/log"], function(r, url, log) {
    var exports = {};

    function zeroQuantity(recordId) {
        var record = r.load({
            id : recordId,
            type : r.Type.INVENTORY_NUMBER
        });
        
        try {
            record.setSublistValue({
                sublistId : 'locations',
                fieldId : 'quantityonhand',
                line : 0,
                value : 0
            });

            record.save({
                enableSourcing : true,
                ignoreMandatoryField : true
            });
        }
        catch (e) {
            alert(e.message);
        }
        var redirect = url.resolveRecord({
            recordType : 'inventorynumber',
            recordId : recordId
        });
        window.location.href = redirect;
    }

    exports.pageInit = function() { return true; };
    exports.zeroQuantity = zeroQuantity;
    return exports;
});
Thanks!
b
if the field is not editable in the ui, its unlikely to be editable in script
c
You know what? I've been doing this long enough that I should have thought of that. Thanks @battk! Will have to find another way.