Parameters for Server Response in SuiteScript

Understand parameters for writing pages with ServerResponse in SuiteScript. Learn about required options and error handling.

·2 min read·View Oracle Docs

The parameters for the ServerResponse.writePage method in SuiteScript are crucial for generating pages effectively. This method is utilized within server scripts to produce a page output, offering essential capabilities for NetSuite developers.

How Does the ServerResponse.writePage Method Work?

This method enables the generation of web pages based on a specified page object. It’s important to note that the framework allows for various types of page objects, which must be included in the request.

Method Description

  • Generates a page.
  • Returns: void

Supported Script Types

  • Server scripts.
    For more details on the types of scripts available, refer to the SuiteScript 2.x Script Types.

Governance

  • None
    This method does not impose any governance limits on usage.

Module

  • N/http Module
    This method is a member of the N/http module, enabling HTTP functionalities within SuiteScript.

Parent Object

  • http.ServerResponse
    It operates under the ServerResponse object, enabling you to manage HTTP responses.

Parameters

The function requires certain parameters to perform successfully. Here’s a breakdown:

ParameterTypeRequiredDescription
options.pageObjectserverWidget.Assistant
serverWidget.Form
serverWidget.ListrequiredA standalone page object in the form of an assistant, form, or list.

Error Handling

Error handling is a critical aspect when using this method:

  • Error Code: SSS_MISSING_REQD_ARGUMENT
  • Message: Missing a required argument: {param name}
  • Thrown If: The options.pageObject parameter is not specified.

Syntax Example

The following code sample illustrates how you can use the writePage method. Note that the syntax provided is for demonstration and is not a complete functional script.

suitescript
1// Add additional code
2...
3var myPageObj = serverWidget.createList({
4 title: 'Simple List'
5});
6
7ServerResponse.writePage({
8 pageObject: myPageObj
9});
10...
11// Add additional code

This code creates a simple list page object and writes it as a response. Ensure to follow the necessary syntax structure when developing your server scripts.

Related Topics

Source: This article is based on Oracle's official NetSuite documentation.

Key Takeaways

  • The ServerResponse.writePage method generates pages based on a required pageObject parameter.
  • Proper error handling is essential to avoid missing required arguments.
  • This method is essential for server scripts in the SuiteScript framework.

Frequently Asked Questions (4)

What types of page objects can be used with the ServerResponse.writePage method?
The types of page objects that can be used are serverWidget.Assistant, serverWidget.Form, and serverWidget.List.
Is there any governance limit for using the ServerResponse.writePage method?
No, there are no governance limits imposed on the usage of the ServerResponse.writePage method.
What error might occur if the required parameters for ServerResponse.writePage are not provided?
An error with the code SSS_MISSING_REQD_ARGUMENT will be thrown if the options.pageObject parameter is not specified.
Which module do you need to include for using the ServerResponse.writePage method?
The method is part of the N/http module, which must be included to use the ServerResponse.writePage in SuiteScript.
Source: Parameters 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 →