Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I search records by internal id in Netsuite's Suitescript?

Tags:

netsuite

I am trying to implement a search by Category of Inventory Items in Netsuite using their Suitescript API. The following code works as expected so I know I have successful remote communication. But I am stumped as to how to go about searching by Category.

function NSTest() {
    var items = [];

    var filters = [
        //new nlobjSearchFilter('price',null,'lessthan','20'),
        new nlobjSearchFilter('thumbnailurl',null,'isnotempty')
        //new nlobjSearchFilter('internalid',null,'is','60635')
        ];

    var columns = [
        new nlobjSearchColumn('itemid'),
        new nlobjSearchColumn('salesdescription'),
        new nlobjSearchColumn('storedisplaythumbnail'),
        new nlobjSearchColumn('baseprice')
        ];

    var results = nlapiSearchRecord('inventoryitemdetail',null,filters,columns);
    for(var i=0,l=results.length; i < l; i++) { 
        var result = results[i];
        var price   = result.getValue('baseprice');
        var thumbImage  = result.getText('storedisplaythumbnail');
        var desc    = result.getValue('salesdescription');
        var name    = result.getValue('itemid');
        var img   = 'http://shopping.netsuite.com'+thumbImage;
        var item = {desc:desc, price:price, name:name, img:img};
        items.push(item);
    }
    response.write(JSON.stringify(items));
}

This works correctly but if I uncomment the line:

new nlobjSearchFilter('internalid',null,'is','60635')

it does not. Can anyone guide me toward searching items by category in Suitescript?

like image 203
Adrian Bartholomew Avatar asked Oct 07 '22 06:10

Adrian Bartholomew


1 Answers

Take the quotes off of the internal id number. The search filter for internalid is looking for a number.

like image 93
Corey Avatar answered Oct 12 '22 12:10

Corey