Redirect to a record from the suitelet page

From a suitelet page, to redirect to a record, use the below code:

scriptContext.response.sendRedirect({
    type: https.RedirectType.RECORD,
    identifier: CUSTOM_REC_IDS.eWayBillIRNRec,
    id: eWayBill.internalId
 });

Method Description: Creates a redirect URL that resolves to a NetSuite resource. For example, you could use this method to redirect to a new sales order page for a particular entity.

Returns: void

Supported Script Types: Server scripts

Module: N/https

Governance: None

Required Parameters:

  1. identifier (number | string): The primary ID for this resource. The value you use varies depending on the value of options.type, as follows:
  2. MEDIA_ITEM — Use the internal ID of a file stored in the NetSuite File Cabinet.
  3. RECORD — Use record.Type to identify the appropriate record type.
  4. RESTLET — Use the script ID from the script record of the appropriate RESTlet.
  5. SUITELET — Use the script ID from the script record of the appropriate Suitelet.
  6. TASK_LINK — Use the appropriate Task ID. Supported IDs are listed in Task IDs
  7. type (string): The type of resource to which the script redirects. Use https.RedirectType to set a value for this parameter.

Error Code

  • INVALID_ID
  • Message: You have provided an invalid script id or internal id: {id}
  • Thrown If: The options.type parameter is set to RESTLET or SUITELET, and the script uses an invalid ID for options.identifier or options.id.
  • INVALID_RCRD_TYPE
  • Message: The record type {type} is invalid.
  • Thrown If: The options.type parameter is set to RECORD, and the script uses an unrecognizable string value for options.identifier. To avoid this error, use record.Type to identify the appropriate record type.
  • INVALID_TASK_ID
  • Message: The task ID: {id} is not valid. Please refer to the documentation for a list of supported task IDs.
  • Thrown If: The options.type parameter is set to TASK_LINK, and the script uses an invalid task ID for options.identifier. For a list of valid IDs, see Task IDs.
  • SSS_INVALID_URL_CATEGORY
  • Message: The options.type: {type} is not valid. Please use https.RedirectType enum for supported types.
  • Thrown If: The script uses an unrecognizable string value for the options.type parameter. To avoid this error, use https.RedirectType to set the value.
  • SSS_MISSING_REQD_ARGUMENT
  • Message: Missing a required argument: {param name}
  • Thrown If: The options.identifier or options.type parameter is not specified. Note that this error is thrown if an enum is misspelled within a script. For example, you see this error if you use http.RedirectType.TASKLINK instead of http.RedirectType.TASK_LINK in the options.type field.

Leave a comment

Your email address will not be published. Required fields are marked *