ServerRequest.parameters

Note:

The content in this help topic pertains to SuiteScript 2.0.

Important:

Parameters could include unsantized input, such as cross-scripting (XSS). To avoid XSS vulnerabilities, parameters should not contain any unsanitized input such as <script> tags. Do not use <script> tags in your parameters.

Property Description

The server request parameters, as name:value pairs. Note that if the server request is a Get request, parameters are sent as part of the URL. If the server request is a Post request, parameters are sent within the request body.

Note:

Parameters cannot be arrays. Use JSON.stringify/JSON.parse instead to handle arrays.

Type

Object (read-only)

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Module

N/http Module

Parent Object

http.ServerRequest

Sibling Object Members

ServerRequest Object Members

Since

2015.2

Errors

Error Code

Thrown If

READ_ONLY_PROPERTY

You attempted to edit this property. This property is read-only.

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/http Module Script Samples.

          // Add additional code 
...
// example from a Suitelet

onRequest: function(context) {
    // in the following, context.request is an http.ServerRequest (per Suitelet onRequest(params.request) entry point)
    
    if (context.request.method === 'GET') { 
        // request is coming from a User Event script, for instance, on a form load; parameters are in the URL as name:value pairs (as the query string)

        var myName = context.request.parameters.custpage_nameParam;      // here, 'custpage_nameParam' and 'custpage_phoneParam' are parameter names set
        var myPhone = context.request.parameters.custpage_phoneParam;    // by the requesting script and sent in the HTTP request
    }
    if (context.request.method === 'POST'){ 
        // request is coming from a Submit button click on the form, submitting the form (using a user event script); parameters are in the form fields

        var myName = context.request.parameters.nameFld;   // here, 'nameFld' and 'phoneFld' are field ids on the form for the Name and Phone fields
        var myPhone = context.request.parameters.phoneFld;
    }
}
...
// Add additional code 

        

Related Topics

http.ServerRequest
N/http Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices