Discussions
Be sure you're subscribed to NetSuite communication to stay in the know about monthly happenings, updates and announcements. Subscribe
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', '