Skip to content

Instantly share code, notes, and snippets.

@thisnameissoclever
Created October 10, 2022 16:31
Show Gist options
  • Save thisnameissoclever/2746528c6b6d579ad1a9a16c593df845 to your computer and use it in GitHub Desktop.
Save thisnameissoclever/2746528c6b6d579ad1a9a16c593df845 to your computer and use it in GitHub Desktop.
ServiceNow Animated "Loading" form message during GlideAjax call
var gaSlowGlideAjaxCall = new GlideAjax('{some_glideajax_script_include');
//todo: Set the second argument to the method you want to execute from your GlideAjax Script Include
gaSlowGlideAjaxCall.addParam('sysparm_name', '{some_slow_glideajax_script_method');
//todo: Add whatever other GlideAjax parameters you need to add below, such as:
gaSlowGlideAjaxCall.addParam('record_sys_id', g_form.getUniqueValue());
//Show animated form message: "Processing request..."
//This will continue to show and animate until we call g_form.clearMessages(),
// which we'll do in the callback function
//todo: Update message from "Processing request" to whatever is appropriate to your situation.
showSimpleLoadingMessage('Processing request');
//The below callback function (which clears the animated form message) will only execute
// when the slow GlideAjax call is complete. Until then, the animated message will continue.
gaSlowGlideAjaxCall.getXMLAnswer(function (answer) {
//todo: Do something with the answer here...
//Clear the animated "Processing request" form message and add a new one.
g_form.clearMessages();
//todo: Replace the below message with something appropriate to your situation.
g_form.addInfoMessage('Processing complete!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment