Code

No getXMLWait() in client scripts


Performance
1h 15m to fix

Why is this an issue?

GlideAjax getXMLWait() function tells the user that he must wait for an answer. This causes a block of code continuation until you get a response.

On slow connections, this will bring slow response to the end user. Imagine a person trying to access, from your mobile phone 3G, some page in ServiceNow Portal and a client script prevents it because it is looking for information that does not even suit it.

A example of this, would be:

1var ga = new GlideAjax("HelloWorld"); 2ga.addParam("sysparm_name", "helloWorld"); 3ga.addParam("sysparm_user_name", "Bob"); 4ga.getXMLWait(); 5alert(ga.getAnswer());

Best practices

Synchronous calls to the server can cause the application to seem unresponsive to the end user. Consequently, the best way to do this communication is using asynchronous calls, such as getXML(), since it does not stop any code process flow.

1var comments = gel("dialog_comments").value; 2// Call script include to escape text 3var ga = new GlideAjax('validateComments'); 4ga.addParam('sysparm_name', 'validateComments'); 5ga.addParam('sysparm_comments', comments); 6ga.getXML(callback); 7 8return false; 9 10function callback(response) { 11 var comments = response.responseXML.documentElement.getAttribute("answer"); 12 comments = trim(comments); 13 if (comments == "") { 14 // If comments are empty, alert the user and stop submission 15 alert("Please enter your comments before submitting."); 16 } else { 17 GlideDialogWindow.get().destroy(); 18 // Set the "Comments" field with comments in the dialog 19 g_form.setValue("comments", comments); 20 }

The code above shows you an excellent example of how to make a responsive call and in a way that does not interfere with end user navigation and usability.

Users with cross-domain visibility
Do not use current.update() in Business Rules

© Copyright 2025. All rights reserved.