JavaScript Log

From ServiceNow Wiki
Home > Script > Debugging > JavaScript Log
Jump to: navigation, search
Note
Note: This article applies to Fuji. For more current information, see JavaScript Log at http://docs.servicenow.com

The ServiceNow Wiki is no longer being updated. Please refer to http://docs.servicenow.com for the latest product documentation.


Scripting Glide and Jelly
Related Topics
Knowledge.gif Get the Glide Reference Book

1 Overview

JavaScript that runs on the browser, such as client scripts, can include a call to jslog() to send information to the JavaScript Log. Users with the admin role can access this log.

2 Using the JavaScript Log

  1. Open the JavaScript log by clicking the debug icon (Debug.gifx.gif).
    • UI14: click the gear icon (GearIconUI14.png) on the banner frame and then click the debug icon.
    • UI11 and Classic: click the debug icon on the banner frame.
    A new pane opens at the bottom of the screen. It shows the JavaScript Log tab and may also show JavaScript Debugger and Field Watcher tabs.
  2. If needed, select the JavaScript Log tab.
  3. Click the clear icon (Eraser.png) to clear the contents of the log, as needed.


Log.png

The log shown above transcribes the events that occurred on the browser side during the loading of the incident list and its filter, below.

Image:incident_list_debug.jpg

Note
Note: In the Calgary release and earlier versions, the JavaScript log displays in a JavaScript Debug Window.


3 Writing to the Debug Log

To write to the debug log in your client-side JavaScript, for example Client Scripts or UI Policies, make a call to the global function jslog().

An example of using jslog() in JavaScript:

function logData(r) {
    lastLogDate = r.responseXML.documentElement.getAttribute("last_log_entry");
    var items = r.responseXML.getElementsByTagName("log");
    jslog("response=" + r.responseText);
}

Additionally, when onLoad client scripts run, the name of the client script and timing information is displayed. This can be useful in determining which onLoad scripts are running and whether they are impacting performance.

4 Debug UI Policies

Enabling the glide.ui.ui_policy_debug property lets you monitor the processing of UI actions. Here are some sample log events from an incident policy that sets fields to read-only if the incident_state is closed.

GlideFieldPolicy: Evaluating condition
GlideFieldPolicy:     incident_state (7) = 7 -> true
GlideFieldPolicy: --->>> TRUE
GlideFieldPolicy:    Setting opened_at disabled to true
GlideFieldPolicy:    Setting opened_by disabled to true
GlideFieldPolicy:    Setting closed_at disabled to true
GlideFieldPolicy:    Setting closed_by disabled to true
GlideFieldPolicy:    Setting company disabled to true
Was this article helpful?
Yes, I found what I needed
No, I need more assistance