Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

GlideScriptedProcessor- Scoped

The GlideScriptedProcessor API provides a customizable URL endpoint that can execute arbitrary server-side JavaScript code and produce output such as TEXT, JSON, or HTML. ServiceNow processors are equivalent to Java servlets.

Use this API in processor scripts to access the processor (servlet) capabilities. There are no constructors for the ScopedGlideScriptedProcessor APIs. The methods are called using the global variable g_processor.

A useful global variable, g_target, is available in processor scripts. It contains the table name extracted from the URL.

The URL to a processor has the format: https://<instance name.servicenow.com>/<path endpoint>.do?<parameter endpoint>=<value> where the path endpoint and parameter endpoint are defined on the processor form.

Parent Topic:Server API reference

GlideScriptedProcessor - redirect(String url)

Redirects to the specified URL.

NameTypeDescription
urlStringDestination URL
TypeDescription
void 
//Do whatever processing you need and redirect to the homepage
g_processor.redirect("/navpage.do")

GlideScriptedProcessor - writeJSON(Object o)

Encodes an object as a JSON string and writes it to the current URL.

NameTypeDescription
oObjectThe object to encode to a JSON string.
TypeDescription
void 
var map = {"key1":"value1","key2":"value2"};
g_processor.writeJSON(map);

GlideScriptedProcessor - writeOutput(String s)

Writes the specified string to the current URL.

NameTypeDescription
sStringThe string to write.
TypeDescription
void 
var name = g_request.getParameter("name");
g_processor.writeOutput("Hello " + name);

GlideScriptedProcessor - writeOutput(String contentType, String s)

Writes the specified string to the current URL in the specified character-encoding.

NameTypeDescription
contentTypeStringSets the content type of the response sent to the client, if the response has not been committed, and may include a character-encoding specification.
sStringString to write.
TypeDescription
void 
var name = g_request.getParameter("name");
g_processor.writeOutput("text/plain", "Hello " + name);