Defining HTML response fields

To define HTML response fields and set their values, use the response.AddFormField() method. It’s a simple method that takes two arguments:

  • fieldname, a string that defines the name of a field to add to the HTML response.
  • fieldvalue, a string that defines the value presented in this HTML response field.

When executed, response.AddFormField() adds the defined field and its value to the response object. The Privileged Access Service reads the response object’s field definitions when it’s time to connect to the web application and creates an HTML response with those fields and their values.

It’s best to supply the fieldvalue string by processing it through the global method encode(). This method ensures that the string is HTML-safe by properly encoding any special symbols such as @. The following example adds a field named “username-field” and sets its value to the current value of LoginUser.Username. The example uses encode() to ensure that whatever value is supplied is HTML safe:

response.AddFormField("username-field", encode(LoginUser.Username));

The custom user-password script should at least define a user-name field and a password field using whatever field names the web application requires. If the application requires additional fields, use response.AddFormField() to name those fields and set their values.

You’ll find the response object and encode() method both described in Scripting environment reference.