JSUtil - escapeAttr(String text)

Escape ampersands commonly used to define URL attributes.

Table 1. Parameters
Name Type Description
text String The text
Table 2. Returns
Type Description
String The text with ampersands properly escaped.

var attr = "sysparm_query=active=true&sysparm_view=special";
 
gs.print(JSUtil.escapeAttr(attr));
Output: This is the returned text. If the text is displayed in the application, the page will render the escaped ampersand with a single ampersand.
sysparm_query=active=true&sysparm_view=special