ANS-1806 · SUITESCRIPT DEVELOPMENT

How to Redirect Users to NetSuite Search Pages Using SuiteScript?

Learn how to programmatically direct users to either a search definition page or directly to search results within NetSuite.

Short answer

NetSuite offers `setRedirectURLToSearch` and `setRedirectURLToSearchResults` within the `nlobjSearch` object to programmatically redirect users. These functions allow navigation to a search definition or its results, supporting existing, ad-hoc, or modified searches. They are primarily used in server-side scripts like afterSubmit user events and Suitelets.

Scenario

Users often require dynamic redirection to specific NetSuite search pages, either to a pre-populated search definition for further refinement or directly to the results of a particular search. This functionality is essential for streamlining workflows and guiding users to relevant data based on script logic.

Solution

NetSuite provides two API functions within the nlobjSearch object to facilitate user redirection to search pages. While these methods are part of SuiteScript 1.0, which is still functional, NetSuite's current recommended approach for new development is SuiteScript 2.x.

The available functions are:

  • setRedirectURLToSearch: This function operates similarly to nlapiSetRedirectURL(type, identifier, id, editmode, parameters) but specifically redirects end users to a populated search definition page. It can be utilized with any type of search held within the nlobjSearch object.
  • setRedirectURLToSearchResults: This function also acts like nlapiSetRedirectURL(type, identifier, id, editmode, parameters) but directs end users directly to a search results page. It is applicable to any search contained within the nlobjSearch object.

Both setRedirectURLToSearch and setRedirectURLToSearchResults can be employed in the following scenarios:

  • With an existing saved search, loaded using nlapiLoadSearch.
  • With an ad-hoc search that is being constructed within SuiteScript.
  • With a search that has been loaded and subsequently modified using methods such as addFilter, setFilters, addFilters, addColumn, addColumns, or setColumns, without being saved.

These methods are primarily designed for server-side execution and are supported in afterSubmit user event scripts and Suitelets. While client scripts can initiate redirects, the direct execution of these nlobjSearch methods occurs server-side.

Expert NetSuite Support

Need help with this NetSuite issue?

SuiteScript Development consulting and configuration support

Talk to a consultant