SuiteScript’s ‘N/Search’ filterExpression – Don’t forget it!

This came up yesterday. Here is my note regarding how it works.

If you create a search in SuiteScript 2.0, you can set a filter expression via the filters property.

var mySearch.create({
   type: [whatever type you like],
   columns: [ search.createColumn({ name: 'internalid'... }),
   filters: [
      ['internalid', 'anyof', [more filter stuff here]]
 }

This works great. It accepts the advanced filter, no problem! However, when I load an existing saved search, I cannot submit a filter expression in the same way. Here’s how that works.

var mySearch.load({
   id: [an id of an existing saved search]
};
mySearch.filterExpression = [
   ['internalid', 'anyof' [more filter stuff here]]
];

When you load an existing search and want an advanced filter expression, you must use the filterExpression property!

One thought on “SuiteScript’s ‘N/Search’ filterExpression – Don’t forget it!

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s