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.

·3 min read·View Oracle Docs

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 TypeNameReturn TypeSupported Script TypesDescription
Methodredirect.redirect(options)voidSuitelets, beforeLoad user events, synchronous afterSubmit user eventsRedirects to the URL of a Suitelet available externally.
Methodredirect.toRecord(options)voidSuitelets, beforeLoad user events, synchronous afterSubmit user eventsRedirects to a specific NetSuite record.
Methodredirect.toRecordTransform(options)voidworkflow action scriptsRedirects to a standard or custom transaction instance.
Methodredirect.toSavedSearch(options)voidafterSubmit user eventsRedirects to a saved search.
Methodredirect.toSavedSearchResult(options)voidafterSubmit user eventsRedirects to a saved search result.
Methodredirect.toSearch(options)voidafterSubmit user eventsRedirects to a search.
Methodredirect.toSearchResult(options)voidafterSubmit user eventsRedirects to search results.
Methodredirect.toSuitelet(options)voidSuitelets, beforeLoad user events, synchronous afterSubmit user eventsRedirects to a Suitelet.
Methodredirect.toTaskLink(options)voidSuitelets, beforeLoad user events, synchronous afterSubmit user eventsRedirects 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:

suitescript
1/**
2 * @NApiVersion 2.x
3 */
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.TASK
10 });
11 taskRecord.setValue('title', taskTitle);
12
13 var taskRecordId = taskRecord.save();
14
15 redirect.toRecord({
16 type: record.Type.TASK,
17 id: taskRecordId
18 });
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?
The N/redirect module supports Suitelet scripts, beforeLoad user events, and synchronous afterSubmit user events.
Can the N/redirect module be used in backend scenarios like CSV Imports or Scheduled Scripts?
No, the N/redirect module is not supported in backend contexts such as CSV Imports or Scheduled Scripts.
Is any specific configuration needed for redirecting to Suitelets externally?
Yes, Suitelets must be set to 'Available Without Login' in their Script Deployment settings when redirected to externally.
Does the N/redirect module support asynchronous afterSubmit user events?
No, the N/redirect module does not support asynchronous afterSubmit user events.
Source: N/redirect Module Members Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Platform

View all Platform articles →