GlideScriptedProcessor - Scoped

  • 릴리스 버전: Australia
  • 업데이트 날짜 2026년 03월 12일
  • 소요 시간: 3분
  • 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.

    GlideScriptedProcessor - redirect(String url)

    Redirects to the specified URL.

    표 1. Parameters
    Name Type Description
    url String Destination URL
    표 2. Returns
    Type Description
    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.

    표 3. Parameters
    Name Type Description
    o Object The object to encode to a JSON string.
    표 4. Returns
    Type Description
    void
    var map = {"key1":"value1","key2":"value2"};
    g_processor.writeJSON(map);

    GlideScriptedProcessor - writeOutput(String s)

    Writes the specified string to the current URL.

    표 5. Parameters
    Name Type Description
    s String The string to write.
    표 6. Returns
    Type Description
    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.

    표 7. Parameters
    Name Type Description
    contentType String Sets the content type of the response sent to the client, if the response has not been committed, and may include a character-encoding specification.
    s String String to write.
    표 8. Returns
    Type Description
    void
    var name = g_request.getParameter("name");
    g_processor.writeOutput("text/plain", "Hello " + name);