Create a search using SuiteScript 2.0 by providing the result range


817
Hi guys, Today I am just explaining a very simple way to add a search in your code. Basically we face some difficulties while creating a search in our scripts. So just follow my code and create your own search without spending anything...

// This is the easy way to add filter.
var filters=[
	["trandate","within",fdate,tdate],
	"AND",
	["type","anyof","CustPymt"],  
	"AND", 
	["amountremainingisabovezero","is","T"]
];

//This is a very easy way to add column (If you didn't use the summary then just remove that line from code.)
var columns = [];
    columns[0] = search.createColumn({
    name: 'entity',
    summary: search.Summary.GROUP
    });
    var search1 = search.create({
       type: "customerpayment",
       filters: filters,
       columns: columns
    });     
    var resultSet = search1.run();
    var resultRange = resultSet.getRange({
    start: 0,
    end: 100
    });
    for (var i=0; i<resultRange.length; i++)    
    {
        var result = resultRange[i];
        var customerId = result.getValue({name: "entity",summary: "GROUP"});
        // if you removed summary from column then please remove it from here too.
    }

This is a 100% working code. We can use this search anywhere is the code in NetSuite Suite Script 2.0 version.
Note: If you need any type of code just let me know and I will serve you in the best way and earliest available time.

Please let me know your comments regarding above code.

Like it? Share with your friends!

817
admin

3 Comments

  1. Hi, i read your blog occasionally and i own a similar one and i was just curious if you get a lot of spam remarks? If so how do you reduce it, any plugin or anything you can suggest? I get so much lately it’s driving me insane so any assistance is very much appreciated.