N/redirect Module for Navigation Customization in NetSuite
The N/redirect module enhances navigation with redirects 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
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category