Tuesday, September 25, 2018

Extract search results via SuiteScript with the ordering similar to the one in the user interface

The member items of the Kit/Package Item record are ordered differently when extracted via SuiteScript as compared to its ordering in the User Interface when viewing the record.
 
In order to extract the member items of a Kit/Package Item and follow the ordering specified in the User Interface, the user should do the following:
 
- Use the nlapiSearchRecord function
- Define the filters
- Define the internal id as one of the result columns
- Use the setSort() method on the Internal Id column of the result set

 
Sample code:
var filters = new Array();
//define filters here

 
var columns = new Array();
columns.push(new nlobjSearchColumn('internalid'));
columns[0].setSort();
//define other columns here

var memberItems = nlapiSearchRecord('item', null, filters, columns);

No comments:

Post a Comment