Search.run()
Method Description |
Runs an on-demand search created with search.create(options) or a search loaded with search.load(options), returning the results as a search.ResultSet. Calling this method does not save the search. Use this method with search.create(options) to create and run on-demand searches that are never saved to the database. After you run a search, you can use ResultSet.each(callback) to iterate through the result set and process each result.
Important:
When you call this method, consider the following:
|
Returns |
|
Supported Script Types |
Client scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Since |
2015.2 |
Errors
Error Code |
Thrown If |
---|---|
|
An unknown search parameter name is provided. |
|
An unsupported value is set for the provided search parameter name. |
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
...
function loadAndRunSearch() {
var mySearch = search.load({
id: 'customsearch_my_so_search'
});
mySearch.run().each(function(result) {
var entity = result.getValue({
name: 'entity'
});
var subsidiary = result.getValue({
name: 'subsidiary'
});
return true;
});
}