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

@KelvinY2025 

Thank you for marking my response as helpful.

💡 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

mads2
Tera Contributor

You cannot use GlideAjax and script includes in workspace. 

For your use case I would consider creating a Data Broker Server Script (sys_ux_data_broker_transform). Here you can do server-side actions based on inputs from your page and return an output based on the script evaluation. Just ensure to check "Mutates server data" to be able to execute the Data resource with an event.

This video briefly describes the concept: https://www.youtube.com/watch?v=QrTc8PTOHmc 

Welcome to our comprehensive tutorial on Transform Data Broker and creating a UI Builder in ServiceNow! 🎉 In this video, we'll walk you through: ✅ What is a Transform Data Broker and its role in ServiceNow. ✅ How to design and configure custom UI Builder components for seamless data integration. ✅

I tried, but it doesn't work now. I have tried this lesson.

Although I still haven't been able to initiate a request in SOW, at least I know that this problem is not facing me alone. Doesn't ServiceNow official know about the existence of this problem and provide a simple and feasible solution?