Identifying and reducing synchronous AJAX calls generated by client scripts

  • Loading a form, such as an incident, takes too long or freezes before any interaction is possible.
  • The Client Transaction Timing widget or log indicates a high amount of browser time for a particular form transaction.


ReleaseRelease: Available since October2011 Preview 1, a multi-line field was added to client scripts. Strings entered here (one per line) are made available to the client script as localized messages without the need for an AJAX call, using getMessage(msg) syntax.



ReleaseRelease: GlideAjax replaced the AjaxEvaluate functionality in the Fall 2009 Stable 2 release.



NoteNote: To call a business rule from a client script, use GlideAjax. The GlideAjax class allows the execution of server-side code from the client.



  • Use of GlideRecord invocations in onLoad and onChange client scripts.
  • Use of getReference invocations in onLoad and onChange client scripts.



Client scripts add functionality to the forms user interface and can retrieve data from the server to populate fields or inform logic that affects the user's interactivity with the form. While there is a variety of methods for retrieving data from the server after the initial page request, some of these methods employ synchronous retrieval. This pauses the interactivity with the browser window until the data is retrieved and the script is executed. Making multiple round-trip requests for data after a form has loaded can pause a form for an extended period of time.


To identify synchronous AJAX calls that occur when loading a form:


ImportantImportant: A browser with debugging capability is required for this sequence. Firefox comes with an add-on called Firebug, which is used in the following documented steps. Other browsers such as Chrome, Safari, and recent versions of Internet Explorer have similar utilities.


    1. In the ServiceNow instance, locate the record link for the slow form.

    1. Turn on the Firebug add-on and enable the following settings:

        1. Enable the Net panel.

      1. As the content type, select XHR.

    1. Click the Clear button, then click the link to the form.

    1. In the Firebug frame, observe whether any entries appear with URL values of POST

    1. Expand each request and examine the data listed in the Post tab for each request.


      NoteNote: Synchronous AJAX requests can be identified as having a sysparm_processor value of AJAXGlideRecord.


    1.  In the Post tab, record the sysparm_chars and sysparm_name values for each synchronous AJAX request.


      ImportantImportant: If multiple requests have identical values for both parameters, then redundant requests for the same data are being issued and can be consolidated.


  1. From the Timeline column, record the combined timing for all synchronous AJAX requests with a sysparm_processor value of AJAXGlideRecord.


    NoteNote: Converting these requests to async with the GlideAjax Application Programming Interface (API) can potentially reduce the time spent on the form load.



To identify the client script that issues a synchronous AJAX call:

    1. Prepare a record link for the slow form.

    1. Click the JavaScript Debugger Window icon, which is the green bug located at the top right corner of the main frame.

    1. In the debugger window, click the Clear link.

    1. Click the link for the form.

  1. The JavaScript Debugger Window displays warning messages for each synchronous AJAX request.


    NoteNote: These messages contain the following text: *** WARNING *** GlideRecord sync query for table: <table_name>


  2. The client script that issued the synchronous request is identified in a debug message immediately following the warning message.


    NoteNote: These messages use the following format: onLoad <client_script_name>



To resolve this issue by consolidating requests:

    1. Refactor and combine existing client scripts that make redundant requests for the same data.

    1. Make the call for the data at the top of a single script.

  1. In the newly combined client script, rewrite previously separate client scripts as functions that can be called after the data is retrieved.


To resolve this issue by utilizing the GlideAjax API:

    1. The GlideAjax API allows for asynchronous calls for data and server-side script processing, which will not pause interaction with the form.

    1. In situations when it is okay for the user to begin interacting with the form prior to client script completion, GlideRecord and getReference() invocations can be replaced with GlideAjax equivalents.


NoteNote: For more information on using GlideAjax, refer to GlideAjax in the ServiceNow product documentation.


  1. Refactor eligible client scripts to use GlideAjax.


If the issue continues to exist after following the steps in this article:


Information For more information on how to submit an incident, see Customer Support.



Additional Information

For more information on related topics, review the following product documentation pages:

For more topic related issues, review the following Knowledge Base article:

Article Information

Last Updated:2019-08-02 21:39:05