ANS-1639 · SUITESCRIPT DEVELOPMENT

How to Redirect to the Scheduled Script Status Page from a Suitelet

Redirect users from a Suitelet to internal NetSuite pages, like the Scheduled Script Status page, using server-side SuiteScript.

Short answer

To redirect to the Scheduled Script Status page from a Suitelet, use the N/redirect module's toTaskLink function with the LIST_SCRIPTSTATUS Task ID. For other internal NetSuite pages, such as records, use N/redirect.toRecord or N/redirect.toSuitelet. This server-side approach ensures proper navigation within NetSuite.

Scenario

Developers often need to redirect users to specific NetSuite pages after a Suitelet processes data or performs an action. While client-side scripts can use window.location, server-side Suitelets require a different approach to navigate to internal NetSuite resources, including standard record pages or special system pages like the Scheduled Script Status page.

Solution

To redirect to a specific URL from within a Suitelet, server-side SuiteScript must utilize the N/redirect module to resolve to a NetSuite resource. Unlike client scripts where window.location is used, Suitelets require a server-side redirect function.

  1. Redirecting to a Record Page

    To redirect to a specific record, such as an Invoice, use the N/redirect.toRecord function. This function requires an options object specifying the record type, ID, and whether it should be opened in edit mode.

javascript
    /**
     * @NApiVersion 2.x
     * @NScriptType Suitelet
     * @NModuleScope SameAccount
     */
    define(['N/redirect'], function(redirect) {
        function onRequest(context) {
            if (context.request.method === 'GET') {
                var invID = context.request.parameters.invoiceId; // Example: get ID from URL parameter
                var isEdit = true; // Example: open in edit mode
                redirect.toRecord({
                    type: 'invoice',
                    id: invID,
                    isEdit: isEdit
                });
            }
        }
        return {
            onRequest: onRequest
        };
    });
  1. Redirecting to the Scheduled Script Status Page

    To redirect to the Scheduled Script Status page, use the N/redirect.toTaskLink function with the appropriate Task ID. The Task ID for the Scheduled Script Status page is LIST_SCRIPTSTATUS.

javascript
    /**
     * @NApiVersion 2.x
     * @NScriptType Suitelet
     * @NModuleScope SameAccount
     */
    define(['N/redirect'], function(redirect) {
        function onRequest(context) {
            if (context.request.method === 'GET') {
                redirect.toTaskLink({
                    id: 'LIST_SCRIPTSTATUS'
                });
            }
        }
        return {
            onRequest: onRequest
        };
    });

For a comprehensive list of all Task IDs that lead to NetSuite special pages, search for "Task IDs" in the NetSuite Help documentation.

Expert NetSuite Support

Need help with this NetSuite issue?

SuiteScript Development consulting and configuration support

Talk to a consultant