How to get record type using nlapiLoadRecord?

I tried to get an item type, such as inventory or non-resources, using the nlapiSearchRecord and nlapiLoadRecord functions.

Here is the code snippet:

var searchresults = nlapiSearchRecord(
        'item', search_id, null, 
        [
            new nlobjSearchColumn('internalid'),
            new nlobjSearchColumn('itemid'),
        ]
    );


if (searchresults) {
    final_message += 'Search Results Length :' + searchresults.length;
    for (var i = 0; searchresults != null && i < searchresults.length; i++) {
        var record = nlapiLoadRecord(searchresults[i].getRecordType(),
            searchresults[i].getId() );

        nlapiLogExecution('log','recordtype', record.getFieldValue('type'));

        nlapiSubmitRecord(record);
    }
}

The log displays “item”, neither “inventory” nor “noninventory”

+4
source share
1 answer

You can extract the type directly from the search, for example:

var searchresults = nlapiSearchRecord('item', search_id, null, 
            [
                new nlobjSearchColumn('internalid'),
                new nlobjSearchColumn('type'),
            ]
        );

To get the same type of element from an element record directly:

    var itemtype = record.getFieldValue('baserecordtype');

Alternatively, you can use, depending on your purpose:

    var otheritemtype = record.getFieldValue('itemtype');
+6
source

All Articles