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.

glide Ajax is not wokring in the Workspace client script in servicenow

sushma9
Tera Contributor

Hi All ,

 I am creating one Ui action in the workspace . Ui action is working fine in the native view but in the Workspace its not working .

Note : Alert is coming with the sys id the record in the workspace and after that its going inside the script include which we are using in the workspace . Same Script include is used in native view and its working fine.

Please find the code : Workspace 

 function onClick(g_form) {
     alert(g_form.getUniqueValue());
     var ga = new GlideAjax('dttl_Ajax_Poc');
     ga.addParam('sysparm_name', 'getpocprivacy');
     ga.addParam('sysparm_numb', g_form.getUniqueValue());
     ga.getXML(HelloWorldParse);

     function HelloWorldParse(response) {
         var answer = response.responseXML.documentElement.getAttribute("answer");
         alert(answer); 
     }
 }
 
Script include :

    getpocprivacy: function() { //Getting PA  Sys_id and Corresponding Required data

        var paSysId = this.getParameter("sysparm_numb"); // declaring the varibale which we are getting from the pa record
        gs.info("Demon" + "PA" + paSysId);
        var information = '';
        var grPA = new GlideRecord('incident'); //
        grPA.addQuery('sys_id', paSysId); // query the sys id with pa record sys id
        grPA.query();
        if (grPA.next()) {
information = grPA.number ;
        }
        return information;





    },
    type: 'dttl_Ajax_Poc'
5 REPLIES 5

zolly
Tera Contributor

Hey all,

I had similar problem, in the scoped application for an UI action button, the GlideAjax call was working well from the Fulfiller view, but not from the Workspace.

In console, I saw the 404 error message for the xmlhttp.do POST request. So I had to dig deeper and this combination of following things helped me (considering that both client & server script are written well, sysparm_name and other parameters are matching, client callable checkbox is checked and so on...):

- Make sure that Script Include is accessible from All application scopes (because AbstractAjaxProcessor is in global scope)

- Paste this method into your script include:

isPublic: function() { return true; },


- When initializing GlideAjax object, use the full API name:

var ga = new GlideAjax("<scope>.<script include name>")


Implemented on MS Edge browser in network-restricted domain.