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.
Source: This article is based on Oracle's official NetSuite documentation.
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 Platform
- Style Object Members for Workbook API in NetSuite
The Style object provides customizable properties for workbook formatting in NetSuite, enhancing report and visualization functionality.
- Asynchronous HTTP Requests with SuiteScript Promises
Use SuiteScript to send asynchronous HTTP requests with promises for efficient error handling and response processing.
- Setting Sublist Field Values in SuiteScript
Set values for sublist fields in SuiteScript using the setSublistValue method. Understand required parameters and error handling.
- In This Help Topic
Explore N/log module guidelines, log levels, and script execution logs for efficient logging in SuiteScript.
Advertising
Reach Platform Professionals
Put your product in front of NetSuite experts who work with Platform every day.
Sponsor This Category