Executing Existing Saved Searches

NetSuite saved searches allow you to create reusable search definitions with many advanced search filters/results display options. Although saved searches must be created in the UI, you can pass the internal ID of the saved search to SuiteScript and re-execute the search on a regular basis. This allows you to keep the searches up-to-date for all who might need to access the results.

To re-execute an existing saved search, you will use nlapiSearchRecord(type, id, filters, columns) .
Note:  
For general information on NetSuite saved searches, see Using Saved Searches in the NetSuite Help Center.
When using the nlapiSearchRecord(...) function to execute an existing saved search, note the following:
*
Only saved searches on record types currently supported by SuiteScript can be executed. For a list of records that support SuiteScript, see SuiteScript Supported Records in the NetSuite Help Center.
*
Saved searches acted on by SuiteScript should be protected. If a saved search is edited after script deployment is complete, the execution of the script could fail. You can add security to a saved search by defining access permissions in the search definition.
Tip : You may want to include the script administrator in an email notification for any time a saved search included in the script is updated. Email notifications can be defined on the Alerts tab of the saved search definition.
*
On a Script record page, if you define a saved search as a List/Record script parameter, only saved searches that are public will appear in the List/Record parameter dropdown field. For information on script parameters, see Creating Script Parameters Overview in the NetSuite Help Center.
*
In nlapiSearchRecord(type, id, filters, columns) , the value of id can be the ID that appears in the Internal ID column on the Saved Searches list page (see figure below). Or it can be the value that appears in the ID column.
If you have created a custom scriptId for your saved search, this will appear in the ID column. Note: To access the Saved Searches list page, go to Lists > Search > Saved Searches.
 
In the following code, a Customer saved search is executed. The ID customsarch57 references a specific saved search.
 

function executeSavedSearch()
{
	// specify the record type and the saved search ID
	var searchresults = nlapiSearchRecord('customer', customsearch57, null, null);
	for ( var i = 0; searchresults != null && i < searchresults.length; i++ ) 
	{
		var searchresult = searchresults[ i ];
	}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值