ServerRequest.parameters
Ensure that parameters are properly validated to avoid cross-site scripting (XSS) injections. 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) |
Module |
|
Parent Object |
|
Sibling Object Members |
|
Since |
2015.2 |
Errors
Error Code |
Thrown If |
---|---|
|
You attempted to edit this property. This property is read-only. |
Syntax
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