Issue with pulling JSON data in SuiteScript – NetSuite

When you send the NS object to the log function I believe it goes through a custom JSON.stringify process so if you want to just inspect values you can do:

var oldRecObj = JSON.parse(JSON.stringify(oldRec));

A snippet I often use for dealing with sublists is:

function iter(rec, listName, cb){
    var lim = rec.getLineCount({sublistId:listName});
    var i = 0;
    var getV = function (fld){
        return rec.getSublistValue({sublistId:listName, fieldId:fld, line:i});
    };
    var setV = function(fld, val){
        rec.setSublistValue({sublistId:listName, fieldId:fld, line:i, value:val});
    };
    for(; i< lim; i++){
        cb(i, getV, setV);
    }
}

and then

iter(oldRec, 'apply', function(idx, getV, setV){
    var oldApplied = getV('applied');
});

Leave a comment

Your email address will not be published. Required fields are marked *