Don’t Miss it: Top Strategies for Driving Diversity

days / hours / minutes / seconds

Register Here »
NetSuite logo
NETSUITE RESOURCES
workplace by meta logo
FUTURE
OF WORK WORKPLACE BY META
University icon
CUSTOMER EDUCATION blog
Atlassian Logo
Adoption blog
How-to
November 30, 2023
|
1 min
reading time

SuiteScript 2.0: Adding filter expressions with or without formulas

Share this article
/*SoMe buttons*/ <-- Facebook Share Button Code --> <-- Facebook Share Button Code --> <-- Twitter Share Button Code --> <-- Twitter Share Button Code --> <-- Linkedin Share Button Code --> <-- Linkedin Share Button Code -->

In NetSuite SuiteScript 2.0, there are two ways to filter expressions. The first is for when you want just a simple filter and do not need to include any formulas. The second is when you want to add specific details that can be captured by adding formulas.

To help you get started, we’ve broken down the code for both methods for adding filter expressions in NetSuite SuiteScript 2.0. Copy and paste the code samples below to start testing filters yourself.

Filtering Expressions Without Formulas



var objContracts = search.load({
 id: SEARCH_HEADER
 });
 var filterArray = [];
 filterArray.push([field1,'anyof', STATUS_ACTIVE]);
 filterArray.push('and');
 filterArray.push([field2,'anyof', CUSTOMER]);
 objContracts.filterExpression = filterArray;
 var filters = objContracts.filterExpression;
 var arrResult = objContracts.run();
 var arrResultSet = arrResult.getRange({
 start: 0,
 end: 100
 })

Filtering Expressions With Formulas



var objContracts = search.load({
 id: SEARCH_HEADER
 });
 var formulaString = "formulanumeric: CASE WHEN {custrecord_qnz_con_hdr_bal_volume} > 1000 THEN 1 ELSE 0 END";
 var filterArray = [];
 filterArray.push(['field1','anyof', STATUS_ACTIVE]);
 filterArray.push('AND');
 filterArray.push(['field2','anyof', stCustomer]);
 filterArray.push('AND');
 filterArray.push([formulaString, "equalto", "1"]);
 objContracts.filterExpression = filterArray;
 var filters = objContracts.filterExpression;
 var arrResult = objContracts.run();
 var arrResultSet = arrResult.getRange({
 start: 0,
 end: 100
 })

Want More Insights Like These?

With ServiceRocket, you’ll get certainty, expertise and success built into your NetSuite implementation, configuration and custom development. When you work with us, you get access to NetSuite-trained Certified Developers with over 400+ NetSuite scripts and 50+ Suitelet workflows combined. Rest assured that ServiceRocket will help you find success and provide you with the opportunities you need to transform your business.

Do you have NetSuite license management, implementation, administration, support or custom development needs? We’ve got your back! Contact our NetSuite Certified Experts today.

Ensure the highest return on your NetSuite investment with our custom development or administrative services.

Learn MoreServiceRocket Backed - We've got your back badge