Running Searches in Config: Nested Searches

Documentation article about Nested Searches

·4 min read·View Oracle Docs

This section covers the syntax and patterns for defining and resolving searches within config.

Important:

Config searches are limited to a maximum of 1,000 return values or records. Be sure to manage your search criteria so you don't reach this limit and cause errors. For more information, see Search Result Limits.

Basic Syntax

To understand the syntax of a simple search, we'll use the sample below:

json
1{
2 "record": "supportcase",
3 "filters": ["internalid","anyof","${event.supportcase || 0}"],
4 "map": {
5 "id": "internalid",
6 "label": "casenumber"
7 }
8}

The record property sets the search type to run or the record type to search for. In the sample above, we're searching for Case records. You can find the ID of the record or search type using the NetSuite record browser. For more information see, Working with the SuiteScript Records Browser.

The filters property sets the search criteria.

The map property sets what results will be returned. In this example, you'll get back an object with two properties: id and label.

Special Characters in map

You can use special characters in the map section to change how the search results work. Here are some of those characters:

Note:

When you use special characters, remember that they work the same way they do in NetSuite. For example, using group means all other fields you want to return results need to be grouped, counted, or summed. If you use these, it is best practice to have all results grouped or summarized.

Character

Usage

=

Get value

Get text value (label)

[ ]

Get array values (multiselect)

*

Merge search result duplicates of this column value

<

Sort in ascending order

>

Sort in descending order

^

Group by maximum value

?

Count

Sum

~

Average

{

Minimum

}

Maximum

!

Write a value even if it hasn't changed

Get value and Get text

The equals (=) character lets you get a field's value. For example, if you're mapping a select field, this returns the internalid of the selection. Most of the time, the value is returned by default, but the = character makes it more specific.

The number sign (#) character lets you get the field's text instead. With a select field, this returns the label of the selection as you see it in the NetSuite UI.

Multiselect or arrays

The square bracket ([ ]) characters return the result as an array. They are usually used to ensure that the selected options are returned as an array, rather than as a comma-separated list.

Pipe

The pipe (|) character lets you control where the property reads from and where it writes to, separately. It is handy when you need to read from one field but write to another, or when the same field has two different IDs for searching and writing. Another common use for the pipe character is to make sure you can read a field value but not write to it.

Here's an example search that reads from one field and writes to another:

json
"quantity": "quantity|item.quantity"

Here's an example search that only reads the field value:

json
"status": "status#|"

Nested Searches

You can use results from one search in the filters of another search. The nested search runs first and returns an array of internal IDs, then the outer search uses those IDs in its filter.

Important:

If you nest searches the wrong way, it can cause performance issues.

Special Nested Search Properties

The all and default properties are a couple of special search options you'll use often. By default, config searches return up to 1000 results. If you set all: true, you can get more than 1000, but it might slow things down. If there are no results results, config returns an empty array, which might cause errors. The default property gives you a fallback value instead.

The example below shows a second search inside another. The second search is on the record customrecord_nxc_cr and returns a map of custrecord_nxc_cr_asset. This field stores the asset and therefore returns the internal ID of the asset found on the record. It uses a default of 0 to avoid issues if there are no results found in the nested search. Any results found are an array of assets internal IDs, and get excluded from the main search because the nested search is inside of this filter: ["internalid","noneof",

json
1"record": "customrecord_nx_asset",
2 "filters": [
3 ["internalid","anyof","${event.caseassets}"],"and",
4 ["internalid","noneof",{
5 "array": true,
6 "default": "0",
7 "assets": {
8 "record": "customrecord_nxc_cr",
9 "filters": [

Frequently Asked Questions (4)

What happens if I incorrectly set up a nested search in NetSuite?
If nested searches are configured incorrectly, they can lead to performance issues because of inefficient search queries and handling of large datasets.
How can I retrieve more than 1000 results in a nested search?
To retrieve more than 1000 results in a nested search, set the `all` property to `true`. However, be aware that this can negatively impact performance.
What should I consider when using the 'default' property in a nested search?
The `default` property provides a fallback value when no results are found. This prevents errors that can occur if the search returns an empty array.
How does the nested search configuration handle filters on the 'customrecord_nxc_cr' record?
The nested search on the `customrecord_nxc_cr` record filters results by matching `custrecord_nxc_cr_case` and excluding specific tasks with `custrecord_nxc_cr_task`. It returns internal IDs of assets stored in the `custrecord_nxc_cr_asset` field.
Source: Nested Searches Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in General

View all General articles →