N/redirect Module for Custom Navigation in NetSuite
The N/redirect module enhances navigation by setting redirect URLs to Suitelets, records, and searches in NetSuite.
The N/redirect module allows developers to customize navigation within NetSuite by creating redirect links that can either point to internal resources or external URLs. This redirection capability is useful for creating a seamless user experience and can accommodate various targets, including Suitelets, records, and saved searches.
What Can You Redirect To?
You can set up redirects for the following components:
- URL
- Suitelet
- NetSuite Record
- Task link
- Saved search
- Unsaved search
Supported Contexts
The N/redirect module functions effectively in specific contexts:
- Supported: Suitelet scripts, beforeLoad user events, and synchronous afterSubmit user events.
- Not Supported: beforeSubmit or asynchronous afterSubmit user events, backend contexts like CSV Import or Scheduled Scripts.
N/redirect Module Methods
Below is a breakdown of the available methods in the N/redirect module:
| Member Type | Name | Return Type | Supported Script Types | Description |
|---|---|---|---|---|
| Method | redirect.redirect(options) | void | Suitelets, beforeLoad user events, synchronous afterSubmit user events | Redirects to the URL of a Suitelet available externally. |
| Method | redirect.toRecord(options) | void | Suitelets, beforeLoad user events, synchronous afterSubmit user events | Redirects to a specific NetSuite record. |
| Method | redirect.toRecordTransform(options) | void | workflow action scripts | Redirects to a standard or custom transaction instance. |
| Method | redirect.toSavedSearch(options) | void | afterSubmit user events | Redirects to a saved search. |
| Method | redirect.toSavedSearchResult(options) | void | afterSubmit user events | Redirects to a saved search result. |
| Method | redirect.toSearch(options) | void | afterSubmit user events | Redirects to a search. |
| Method | redirect.toSearchResult(options) | void | afterSubmit user events | Redirects to search results. |
| Method | redirect.toSuitelet(options) | void | Suitelets, beforeLoad user events, synchronous afterSubmit user events | Redirects to a Suitelet. |
| Method | redirect.toTaskLink(options) | void | Suitelets, beforeLoad user events, synchronous afterSubmit user events | Redirects to a task link. |
Example Usage
Here's an example script that demonstrates how to set a redirect URL to a newly created task record:
1/**2 * @NApiVersion 2.x3 */4 5require(['N/record', 'N/redirect'], function(record, redirect) {6 function redirectToTaskRecord() {7 var taskTitle = 'New Opportunity';8 var taskRecord = record.create({9 type: record.Type.TASK10 });11 taskRecord.setValue('title', taskTitle);12 13 var taskRecordId = taskRecord.save();14 15 redirect.toRecord({16 type: record.Type.TASK,17 id: taskRecordId18 });19 }20 21 redirectToTaskRecord();22});Important Considerations
- Ensure that Suitelets are set to "Available Without Login" on their Script Deployment settings if you want to redirect to them externally.
- This module is strictly for UI-triggered functions, so ensure adequate context when deploying.
Key Takeaways:
- The N/redirect module allows enhanced user navigation within NetSuite by using various redirects.
- Supports specific user event types and is limited to UI contexts.
- Multiple redirect methods cater to different NetSuite resources.
Frequently Asked Questions (4)
What contexts are supported by the N/redirect module in NetSuite?
Can the N/redirect module be used in backend scenarios like CSV Imports or Scheduled Scripts?
Is any specific configuration needed for redirecting to Suitelets externally?
Does the N/redirect module support asynchronous afterSubmit user events?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
