GlideAjax getXMLWait() not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2016 04:52 AM
Hey,
I'm trying to run simple script on a UI action that gets the group of the connected user. I created the script include and I used it in many other places using Ajax Asynchronous calls. However, when I tried to call it using a synchronous call, I got a 'null' result, as if the script doesn't wait for the answer to come.
Here's is a snippet from my UI Action containing the ajax call.
var ajax = new GlideAjax('GetAssignementGroup');
ajax.addParam('sysparm_name', 'getGroup');
ajax.getXMLWait();
var group = ajax.getAnswer();
alert(group); //Prints 'null'
As I said, I'm already using the same script include with asynchronous calls and it's working. Do you have any ideas ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2016 07:47 AM
Maybe the scope is the issue then. I always make global Script Includes so I don't ever run into issues. I sincerely wish you luck in getting this figured out as I've exhausted my options and provided ample code that does in fact work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2016 07:49 AM
The other thing you may want to do is throw in some "gs.log()" lines in your script include just to see first, if it's hitting the script include, and if it is, where it's breaking.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2016 07:52 AM
Thank you David, I really appreciate your efforts

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2016 05:05 AM
Script Include (example):
var GetAssignementGroup = Class.create();
GetAssignementGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGroup: function()
{
var _sysID = 'sysID not found';
var gr = new GlideRecord('sys_user_group');
gr.addQuery('name', 'Name of Group I am looking for');
gr.query();
if (gr.next())
_sysID = gr.sys_id.toString();
return _sysID;
}
});
Client Script (example):
function test()
{
var ajax = new GlideAjax('GetAssignementGroup');
ajax.addParam('sysparm_name', 'getGroup');
ajax.getXMLWait();
var group = ajax.getAnswer();
//var answerArray = group.evalJSON();
alert(group);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2017 10:25 AM
Not sure if you found an answer to this issue. getXMLWait() doesn't work in scoped application and that's probably the culprit.
Scoped Applications and Client Scripts: A Primer