GlideURI - Scoped

The GlideURI class is a utility class for handling the URI parameter. The GlideURI class is available in global and scoped scripts.

GlideURI - get(String name)

Returns the specified parameter.

Table 1. Parameters
Name Type Description
name String The parameter name.
Table 2. Returns
Type Description
String The URI for the specified parameter.
var gURI = new GlideURI();
gURI.set('sysparm_query', 'priority=2^active=true' );
var fileString = gURI.get('sysparm_query');
gs.info(fileString);

Output:

priority=2^active=true

GlideURI - getFileFromPath()

Returns the file name portion of the URI.

Table 3. Parameters
Name Type Description
None
Table 4. Returns
Type Description
String The file name portion of the URI.
var gURI = new GlideURI();
 
var fileString = gURI.getFileFromPath();
gs.info(fileString);

GlideURI - GlideURI()

Instantiates an GlideURI object.

Table 5. Parameters
Name Type Description
None

    

GlideURI - set(String name, String value)

Sets the specified parameter to the specified value.

Table 6. Parameters
Name Type Description
name String The parameter name.
value String The value.
Table 7. Returns
Type Description
void
var gURI = new GlideURI();
gURI.set('sysparm_query', 'priority=2^active=true' );
var fileString = gURI.get('sysparm_query');
gs.info(fileString);

Output:

priority=2^active=true

GlideURI - toString(String path)

Reconstructs the URI string and performs the proper URL encoding by converting non-valid characters to their URL code. For example, converting & to '%26'.

Parameters set with the set method are encoded with the URI as well.

Table 8. Parameters
Name Type Description
path String The base portion of the system URL to which the URI is appended.
Table 9. Returns
Type Description
String The URL.
fileString = gURI.toString('https://<your instance>.service-now.com/navpage.do');