javascriptnetsuitesuitescript

Netsuite - How to get Inventory Adjustment worksheet records using a restlet


I am trying to get a record of an Inventory Adjustment worksheet and getting the error:

{'error': {'code': 'INVALID_TRANS_TYP',
  'message': '{"type":"error.SuiteScriptError","name":"INVALID_TRANS_TYP","message":"Transaction type specified is incorrect.

My code is below:

/**
 * @NApiVersion 2.0
 * @NScriptType Restlet
 * @NModuleScope SameAccount
 */

define([
    'N/record',
], function(record) {
    function getInv(data){
    var recordObj = record.load({
        type: "inventoryadjustment",
        id: data.rec,
        isDynamic: true
    });

        return recordObj;
    }
    return {get:getInv};
});

When I go to Transactions>Inventory>Adjust Worksheet>List I can see the list of all inventory adjustments with their ids. The url shows transaction type as Transaction_TYPE=InvWksht,not sure what that should be in script. How can I get this working?


Solution

  • Finally got this working. I simply had to change the type to inventoryworksheet

    /**
     * @NApiVersion 2.0
     * @NScriptType Restlet
     * @NModuleScope SameAccount
     */
    
    define([
        'N/record',
    ], function(record) {
        function getInv(data){
        var recordObj = record.load({
            type: "inventoryworksheet",
            id: data.rec,
            isDynamic: true
        });
    
            return recordObj;
        }
        return {get:getInv};
    });