Basic Syntax

Documentation article about Basic Syntax

·4 min read·4 views·View Oracle Docs

Basic Syntax

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.

--- Context from https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/chapter_N3169369.html --- To access the SuiteScript Records Browser, use the following link:

Go to the SuiteScript Records Browser

Important:

When writing SuiteScript, you must use the IDs listed in the NetSuite Help Center. You can access IDs by viewing a NetSuite record's page source, but not all IDs in the source code are supported in SuiteScript. If you create a script that references an unsupported or undocumented ID, and NetSuite later changes the ID, your script may break.

Not all fields in the SuiteScript Records Browser can be set using SuiteScript. Some fields are read only. Check the NetSuite UI to see if a field can be set. Generally, if you can set a field in the UI, you can set it using SuiteScript. If you cannot set a field in the UI, you cannot set it using SuiteScript. However, you can still get the field's value using SuiteScript.

The SuiteScript Records Browser provides a summary of all records, fields, sublists, search joins, search filters, search columns, and record transformations that are supported in SuiteScript. Information about elements is displayed as a series of tables.

To find SuiteScript-supported records and IDs:

  1. Open the SuiteScript Records Browser.

    Only records that officially support SuiteScript are listed in the SuiteScript Records Browser.

  2. Click the record you want to reference in SuiteScript.

    All IDs currently supported for the record are listed.

The following table provides examples of objects and methods that use each type of ID:

ID Type

Object Examples

Method Examples

Field IDs

  • [serverWidget.Field](section_4325837128.html

Special Characters in map

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#|"

Get value and Get text

Special Characters in

Frequently Asked Questions (4)

What is the 'record' property used for in a SuiteScript search syntax?
The 'record' property is used to specify the type of record to search for in SuiteScript. In the provided example, it searches for support case records.
How can I verify if a field can be set using SuiteScript?
Check the NetSuite UI to see if a field can be set. Generally, if you can set a field in the UI, you can also set it using SuiteScript. Otherwise, it will be read-only in SuiteScript.
What happens if I use an unsupported ID in my SuiteScript?
If you use an unsupported or undocumented ID in your SuiteScript, your script may break if NetSuite changes the ID in future updates.
How can I find SuiteScript-supported record IDs?
You can find SuiteScript-supported record IDs by opening the SuiteScript Records Browser in NetSuite and selecting the record you want to reference.

Weekly Update History (1)

Field Service Managementupdated

Updated Running Searches in Config to add a note on search result limits.

View Oracle Docs
Source: Basic Syntax 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 Field Service Management

View all Field Service Management articles →