Tip 19: Add Filter to search.load in Netsuite Suitescript 2.0

Hello Friends,

We all know how to add filters while creating a search in Suitescript, as search.create() has a parameter called filters.

Still I am adding it here for anybody who finds difficult to create a search:

var mySearch= search.create({
type: “folder”,
columns: [
“name”,
“internalid”,
“numfiles”
],
filters: [
search.createFilter({
name: ‘name’,
operator: search.Operator.IS,
values: [folderName]
})
]
});

 

Now let’s see how can we add filter to an already existing saved search created either in UI or by search.create() & then search.save().

    var mySearch = search.load({
id: ‘customsearch_test_search’
});
//Add Filter to search
var filter1 = search.createFilter({
name: ‘name’,
operator: search.Operator.IS,
values: [selectedName]
});
mySearch.filters.push(filter1);

I hope this small tip will help you.

Happy Coding 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s