ANS-0199 · SAVED SEARCHES & FORMULAS

Scripting NetSuite Saved Searches: Accessing Multiple Formula Fields

NetSuite scripts face limitations when retrieving multiple formula fields from a saved search if they share the same summary type, requiring a specific workaround.

Short answer

NetSuite scripts cannot directly access multiple formula fields with identical summary types from a single saved search. To overcome this, assign distinct custom labels to each formula field within the search. In your SuiteScript 2.x code, iterate through the search result columns and identify the desired formula fields by their unique labels or formulas.

Scenario

When working with NetSuite saved searches in SuiteScript, users may encounter a limitation where it is not possible to directly access two formula-type fields that share the same summary type. For instance, if a saved search on Sales Orders includes a formula (numeric) field summing {rate}*{quantity} and another summing {rate}*{quantitybilled}, a script will not be able to retrieve both formula fields simultaneously.

Solution

One potential workaround involves splitting the saved search into two separate searches and using filters in the script to correlate the data from the second search with the first. A more direct and commonly used solution is to ensure that each formula field in the saved search has a distinct custom label. For example, if a saved search includes a formula numeric field for {rate}*{quantity} and another for {rate}*{quantitybilled}, assign unique custom labels to each. In SuiteScript 2.x, within the script, access the columns property of a search.Result object. Iterate through these columns, and use the label property of each search.Column object to find the specific formula field required. Alternatively, the formula property of the search.Column object can also be used for identification.

Expert NetSuite Support

Need help with this NetSuite issue?

Saved Searches & Formulas consulting and configuration support

Talk to a consultant