Using Saved Search in REST Web Services

REST web services support the retrieval of and execution of saved searches. You can retrieve both individual saved searches, and lists of saved searches.

A saved search is a reusable search definition that can include advanced search filters and results display options. Saved search results help with reporting, tracking, business analysis, and strategic decision-making. For general information about saved searches, see Defining a Saved Search.

REST web services enables you to get a list of existing saved search IDs that are available to the current user and role. Each saved search contains information about its record type.

You can also execute an individual saved search using either the internal ID or the script ID of the saved search.

The operation to retrieve or run saved searches can be executed both synchronously and asynchronously.

REST web services support search features such as standard and custom fields, joins, formulas, summary and aggregation columns, nulls, Unicode, and long text.

REST web services uses the following endpoints for saved search:

When you run a query for a list of saved searches, pagination is supported. For information about pagination through search results, see Collection Paging.

Limitations of Using Saved Searches in REST Web Services

Note the following limitations of saved searches in REST.

  • Creating, editing, or deleting saved searches through REST is not supported. You cannot override saved search criteria, filters, or sorting.

  • Returning the complete saved search definition is not supported.

Sample Code

The following samples demonstrate getting and executing saved searches in REST web services.

The following sample shows how to get a list of saved searches.

            Request

GET https://demo123.suitetalk.api.netsuite.com/services/rest/query/v1/savedsearch

Result

{
    "links": [
        {
            "rel": "self",
            "href": "https://demo123.suitetalk.api.netsuite.com/services/rest/query/v1/savedsearch/",
            "method": "GET"
        }
    ],
    "count": 27,
    "hasMore": false,
    "items": [
        {
            "links": [],
            "id": "customsearch3",
            "internalid": "3",
            "recordtype": "Execution Results",
            "title": "Execution Results Search"
        },
        {
            "links": [],
            "id": "customsearch_lsa_contact_msgfr_max_date",
            "internalid": "20",
            "recordtype": "Contact",
            "title": "LSA Contact Message-From Max Date Search"
        },
        {
            "links": [],
            "id": "customsearch_lsa_contact_call_max_date",
            "internalid": "21",
            "recordtype": "Contact",
            "title": "LSA Contact Call Max Date Search"
        },
        {
            "links": [],
            "id": "customsearch_balance_gt_100",
            "internalid": "40",
            "recordtype": "Account",
            "title": "Account Balance gt 100"
        }
        ...
    ],
    "offset": 0,
    "totalResults": 27
} 

          

The following sample shows how to get a specific saved search.

            Result

{
    "links": [
        {
            "rel": "self",
            "href": "https://demo123.suitetalk.api.netsuite.com/services/rest/query/v1/savedsearch/customsearch_balance_gt_100/result",
            "method": "GET"
        }
    ],
    "count": 13,
    "hasMore": false,
    "items": [
        {
            "links": [],
            "balance": 111.804,
            "displayname": "Acc. Dep-Leasehold Improvements",
            "email": "sa.sha@example.com",
            "generalratetype": {
                "links": [],
                "id": "CURRENT",
                "refName": "Current"
            },
            "internalid": "21",
            "isinactive": false,
            "name": "Acc. Dep-Leasehold Improvements",
            "subsidiary": {
                "links": [],
                "id": "1",
                "refName": "Parent Company"
            },
            "type": {
                "links": [],
                "id": "FixedAsset",
                "refName": "Fixed Asset"
            }
        },
        {
            "links": [],
            "balance": 500,
            "displayname": "Advertising",
            "generalratetype": {
                "links": [],
                "id": "AVERAGE",
                "refName": "Average"
            },
            "internalid": "59",
            "isinactive": false,
            "name": "Advertising",
            "subsidiary": {
                "links": [],
                "id": "1",
                "refName": "Parent Company"
            },
            "type": {
                "links": [],
                "id": "Expense",
                "refName": "Expense"
            }
        }
     ...
    ],
    "offset": 0,
    "totalResults": 13
} 

          

Related Topics

General Notices