Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to make a Glide Ajax call in Workspace Client Script ?

KelvinY2025
Tera Contributor

function onClick(g_form) {
    g_modal.confirm("Confirm", "Are you sure ?", function(response) {
        doSubmit();
    }, {
        cancelTitle: "Cancel",
        confirmTitle: 'Confirm'
    });

    function doSubmit() {
        console.log("doSubmit");  <= can console log 
 
        var ga = new GlideAjax('uiBuilderAction');
        ga.addParam('sysparm_name', 'cancelIncidentIncident');
        ga.addParam('sysparm_id', g_form.getUniqueValue());
        ga.getXMLAnswer(function(response) {
            if (response) {
                var result = response;
                if (result != 'success') {
                    g_form.addErrorMessage('Error: ' + result);
                } else {
                    g_form.save();
                }
            } else {
                g_form.addErrorMessage('No response from server or invalid response.');
            }
        });
    }
}

Error meg:  
POST https://dev306480.service-now.com/xmlhttp.do 404 (Not Found)
Unhandled exception in GlideAjax. undefined
8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@KelvinY2025 

You should check these things

1) script include is client callable and is Made Accessible to All Application Scopes

2) you are calling the correct script include with complete API name

3) UI action and script include are in same scope

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

1. is made for All application scopes

KelvinY2025_0-1763431851131.png

2. Client called is right in classes page, is SOW page fail, ChatGPT told SOW no support 

GlideAjax;
3. UI action and Script Include are in same scope;
this is a way to resolve

 

Discover how to solve the common issue of `GlideAjax` returning undefined when checking for record attachments in ServiceNow Workspace. Follow our step-by-step solution to ensure seamless user experience. --- This video is based on the question https://stackoverflow.com/q/77053260/ asked by the ...

@KelvinY2025 

your script include is not accessible from all scopes.

please change that and then check

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

your script include is not accessible from all scopes.

please change that and then check     ??

Why do you say that? Can you teach me specifically how to make it accessible to all areas?