Wednesday, May 15, 2019

Manipulate search result and pass it as array of name/value pairs in the addRow method

Below is the sample code on how to pass result to the array of name/value pairs in the addRow method

var list = nlapiCreateList('List');
var result = nlapiSearchRecord('salesorder',<customsearchid>);

if (result!=null)
  var columns = result[0].getAllColumns();

   for (var i=0; i<columns.length; i++)
      list.addColumn(columns[i].getName(), 'text', columns[i].getName());

//Loop through all search results and use nlobjSearchResult object methods
//to get the  values for specific fields and pass it on the array of name/values
for (var x = 0; x<result.length; x++)
var searchresult = result[ x ];
var location = searchresult.getText('location');
var memo = searchresult.getText('memo');
var amount = searchresult.getValue('amount');
var res = new Object();
res['location'] = location ;
res['memo'] = memo;
res['amount'] = amount;


No comments:

Post a Comment