Discussions
Join the NetSuite community to innovate, connect, and discover what’s next.
SuiteWorld brings thousands of innovators, builders, and leaders together to learn, connect, and shape what’s next. This October, explore how to build a stronger foundation for growth through inspiring keynotes, major product reveals, hands-on sessions, and unforgettable moments—all in one place for our biggest event of the year. Register now
Advanced Search Using Expressions in SuiteScript
Saved Search in NetSuite is a powerful feature. In the UI, one can build a saved search using expressions. To do this , check the “USE EXPRESSIONS” box.For example, we want to build a saved search that has the following criteria:
Criteria : (Item =ItemID1 & OrderType=OrderTypeId1 &
OrderTypeUsage=OrderTypeUsageId1) or
(Item =ItemID2 & OrderType=OrderTypeId2 &
OrderTypeUsage=OrderTypeUsageId2) or (Item =ItemID3 & OrderType=OrderTypeId3
& OrderTypeUsage=OrderTypeUsageId3) ……
The following script demonstrates how to achieve this:
var transactionDate = record.getFieldValue('trandate'); var filters = []; var fExp = []; for ( i = 0; i < data.length; i += 1) { filters.push(['custrecord_tintri_order_type_item', 'anyof', data[i].item]); filters.push('and'); //Make sure not empty if (!isEmpty(data[i].orderType)) { filters.push(['custrecord_tintri_order_type', 'anyof', data[i].orderType]); } else { filters.push(['custrecord_tintri_order_type', 'anyof', '