search.create(options)
Method Description |
Creates a new search and returns it as a search.Search object. The search can be modified and run as an on demand search with Search.run(), without saving it. Alternatively, calling Search.save() will save the search to the database, so it can be reused later in the UI or loaded with search.load(options).
Note:
This method is agnostic in terms of its The search.create(options) method also includes a promise version, search.create.promise(options). For more information about promises, see Promise Object.
Important:
When you use this method to create a search, consider the following:
|
Returns |
|
Supported Script Types |
Client and server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Since |
2015.2 |
Parameters
The options parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
string |
required |
The search type that you want to base the search on. Use the search.Type enum for this argument. |
2015.2 |
|
search.Filter | search.Filter[] | Object | Object[] | string | string[] |
optional |
A single search.Filter object, an array of search.Filter objects, a search filter expression, or an array of search filter expressions. A search filter expression can be passed in as an Object with the following properties:
For more information about these properties, see Filter Object Members. If a provided filter value has an incorrect type (for example, a string instead of a number), the filter value is ignored. For server scripts, a log entry is created when an incorrect type is provided.
Note:
You can further filter the returned search.Search object by adding additional filters with Search.filters or Search.filterExpression. |
2015.2 |
|
Object[] |
optional |
Search filter expression for the search as an array of expression objects. A search filter expression is created when an array of JavaScript objects are passed through the
Note:
A filter expression is automatically recognized by NetSuite. Filter expressions should not be explicitly denoted when scripting. A filter expression should be used with the |
2016.2 |
|
search.Column | search.Column[] | Object | Object[] | string | string[] |
optional |
A single search.Column object or array of search.Column objects. You can optionally pass in an Object or array of Objects with the following properties to represent a Column:
For more information about these properties, see Column Object Members. |
2015.2 |
|
string |
optional |
The application ID for this search. |
2019.2 |
|
search.Setting | search.Setting[] | Object | Object[] | string | string[] |
optional |
Search settings for this search as a single search.Setting object or an array of search.Setting objects. Search settings let you specify search parameters that are typically available only in the UI. See Search.settings. You can optionally pass in an Object or array of Objects with the following properties to represent a setting:
For more information about these properties, see Setting Object Members. |
2018.2 |
|
string |
optional |
The name for a saved search. The title property is required to save a search with Search.save(). |
2015.2 |
|
string |
optional |
Script ID for a saved search. If you do not set the saved search ID, NetSuite generates one for you. See Search.id. |
2015.2 |
|
boolean |
optional |
Set to This parameter sets the value for the Search.isPublic property. |
2016.2 |
Errors
Error Code |
Thrown If |
---|---|
|
The |
|
The |
|
Required parameter is missing. |
Syntax
The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/search Module Script Samples.
//Add additional code
...
var mySalesOrderSearch = search.create({
type: search.Type.SALES_ORDER,
title: 'My Second SalesOrder Search',
id: 'customsearch_my_second_so_search',
columns: [{
name: 'entity'
}, {
name: 'subsidiary'
}, {
name: 'name'
}, {
name: 'currency'
}],
filters: [{
name: 'mainline',
operator: 'is',
values: ['T']
}],
settings: [{
name: 'consolidationtype',
value: 'AVERAGE'
}]
});
...
//Add additional code