getXMLWait is the GlideAjax method that holds a client script until the server has finished running a script include function. The result is read afterward with getAnswer(). Execution order stays predictable, but while the browser waits the page can feel frozen. The asynchronous getXML call with a callback is the usual choice, and getXMLWait cannot run in scoped applications.
How a GlideAjax request is assembled
A GlideAjax request starts with a constructor that names the script include class. Parameters are then attached with addParam, and the first of those calls has to set sysparm_name to the function to run inside that class. Building the object and adding parameters happens in the browser. Nothing reaches the server until a send method runs.
getXMLWait is one of the send methods. The other two are getXML and getXMLAnswer, both asynchronous. The three differ in what the client does while the server works, and that difference drives the decisions below.
Naming the pieces so the call succeeds
Three names have to line up. The argument to the constructor must match the script include name exactly, and the script include must have the Client callable check box selected. The value in sysparm_name must match a function inside that class. Any extra parameter must begin with sysparm_.
Four names are predefined and should not be used for your own values: sysparm_name, sysparm_function, sysparm_value and sysparm_type. Checking these names first is the quickest way to rule out a call that returns nothing.
What the server does while getXMLWait waits
The server processes a getXMLWait request synchronously. It does not take further requests from the same client until the current one has finished. That is the source of the ordering guarantee: a later request from that client cannot overtake this one. The cost is that the browser session is waiting on the same reply.
The call takes no parameters and returns nothing. The value is picked up with getAnswer(), which retrieves the result of the server-side method called through getXMLWait. Because getAnswer() sits on the line after the call, the answer is in hand when that line runs. This is the defining difference from the callback pattern, where the code that uses the value lives inside a separate function.
A synchronous example in plain terms
Picture a script include with one function. It reads a user name from the request parameters and returns a greeting built from it. The client creates a GlideAjax object for that class, sets sysparm_name to the greeting function, adds the user name as a second parameter, calls getXMLWait, and reads the greeting with getAnswer.
var ga = new GlideAjax('GreetingAjax');
ga.addParam('sysparm_name', 'greetUser');
ga.addParam('sysparm_user_name', 'Bob');
ga.getXMLWait();
var greeting = ga.getAnswer(); // the reply is in hand because the call above has finished
The matching script include extends AbstractAjaxProcessor, which is what makes it a GlideAjax processor:
var GreetingAjax = Class.create();
GreetingAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
greetUser: function() {
return 'Hello ' + this.getParameter('sysparm_user_name') + '!';
},
type: 'GreetingAjax'
});
Comparing getXMLWait with getXML and getXMLAnswer
The three methods differ on whether the client waits, whether a callback is needed, and how the result comes back.
| Method | Client waits for the server | Callback needed | How the result comes back |
|---|---|---|---|
| getXMLWait() | Yes, the call blocks | No | Read with getAnswer() after the call returns |
| getXML(callback) | No, asynchronous | Yes | Passed to the callback function when the server replies |
| getXMLAnswer(callback, additionalParam, responseParam) | No, asynchronous | Yes | The answer element of the response goes to the callback, with optional extra arguments |
getXML is the preferred method. It does not hold up other client code, and its callback is where the result is handled. getXMLAnswer is also asynchronous, but it narrows the response to the answer element and accepts two optional extras that are handed to the callback function. The getXMLAnswer walkthrough works through that callback pattern in full.
getXMLWait sits at the other end of the table. It needs no callback and it guarantees order, but it is the method that blocks the client and the one that cannot run in scoped applications.
When a synchronous call is justified
A synchronous call fits a script that cannot continue without the GlideAjax response. A typical case is a client step that decides what to show or whether to proceed, where the next line depends directly on the server’s answer. The session stops until the response arrives, and that stop is the cost you accept.
Before choosing it, check whether the logic that consumes the answer can move into a callback. An asynchronous call leaves other client code running, so the form stays responsive during the request. If the synchronous call is still the right fit, keep it narrow: a lookup that is small, fast and needed on the spot. A slow network or a heavy server function lengthens the wait, and the person using the form feels it.
Do not use AJAXEvaluateSynchronously as a substitute. The synchronous GlideAjax route is getXMLWait().
Limits: scoped applications and mobile
The hard limit is that getXMLWait is not available to scoped applications. A script that works in a global scope will not carry over unchanged once the application is scoped, so the call style has to be settled before the code is written. In a scoped application the working pattern is getXML with a callback.
The mobile platform adds its own rules. It does not allow synchronous GlideAjax calls, so any getXMLWait inside a GlideAjax call does not work there. Synchronous GlideRecord calls are not allowed on mobile either, and g_form.getReference() must include a callback parameter, so the value is handled inside a function passed to it rather than returned on the next line.
Who can reach the script include behind the call
The Glide AJAX enabled option, which is the same setting as Client callable, makes a script include available to client scripts, list and report filters, reference qualifiers, or a URL. A request from a user is checked against the access control (ACL) attached to that script include. Selecting the option opens a role selector and creates a role-based Access Control entry for the chosen role.
Privacy settings decide who can run it. The private setting stops guests on public pages from running the include. The public setting lets non-logged-in users run it, which is a security problem if the script returns confidential information.
The system property glide.script.ccsi.ispublic controls this across all client-callable script includes. Those that do not set visibility are public by default. The recommended value is false, which makes them unavailable to non-authenticated users. The property is a safe harbor property: once changed, the value cannot be reverted. Leaving it unset is rated High, with a severity score of 7.5.
A single include can override the property. An isPublic() method returning true or false sets that include’s privacy and takes precedence over glide.script.ccsi.ispublic.
When a Glide AJAX enabled script include queries the database, use GlideRecordSecure in place of GlideRecord. The API Name field is the internal name used to call it from out-of-scope applications.
Alternatives that keep the page responsive
One way to avoid a blocking call is to send data with the form rather than fetch it afterward. The g_scratchpad object carries values from the server to the client once, when the form loads. A display business rule can populate it, for example with a system property value or a flag saying whether the record has attachments. The client then reads those values without a round trip. The limit is timing: a display business rule cannot be triggered dynamically, so data needed after load should come from an asynchronous GlideAjax call.
Setting a reference field is another hidden round trip. When g_form.setValue() is called on a reference field with a bare sys_id, the client asks the server for the display name. Supplying that name as the third parameter avoids the lookup.
GlideRecord can also retrieve server data in a client script, but the client-side GlideRecord API is not supported in scoped applications. In a scoped application, move the lookup into a script include and call it with GlideAjax.
Mistakes that show up in GlideAjax client code
Several errors recur in client scripts that call getXMLWait, and each one breaks a naming, placement or visibility rule.
- Setting sysparm_name anywhere other than the first addParam call.
- Naming an extra parameter without the sysparm_ prefix.
- Reusing a predefined name such as sysparm_value or sysparm_type for a custom value.
- Naming a server function with a leading underscore, which makes it private to the client.
- Overriding initialize or another inherited method of AbstractAjaxProcessor.
- Setting a script include name that differs from the class name, or leaving Client callable unchecked.
- Placing getXMLWait in a scoped application, or inside a GlideAjax call on mobile, and expecting it to run.
Many of these look like a call that returns nothing or throws an error, and the fix sits in the naming or the settings rather than in the function’s logic.
Frequently asked questions
Does getXMLWait need a callback function?
No. The method takes no parameters and returns nothing, and the result is read afterward with getAnswer(). The asynchronous getXML method is the one that uses a callback.
Can a scoped application use getXMLWait?
No. The method is not available to scoped applications. Scoped code should use getXML with a callback instead.
Does getXMLWait work on mobile?
No. The mobile platform does not allow synchronous GlideAjax calls, so getXMLWait inside a GlideAjax call does not work there.