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 05:42 AM
Or, even better yet, send that Group Name as a param in your client script:
var GetAssignementGroup = Class.create();
GetAssignementGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGroup: function()
{
var _sysID = 'sysID not found';
var groupName = this.getParameter('sysparm_groupName');
var gr = new GlideRecord('sys_user_group');
gr.addQuery('name', groupName);
gr.query();
if (gr.next())
_sysID = gr.sys_id.toString();
return _sysID;
}
});
function test()
{
var ajax = new GlideAjax('GetAssignementGroup');
ajax.addParam('sysparm_name', 'getGroup');
ajax.addParam('sysparm_groupName', 'PUT YOUR GROUP NAME HERE');
ajax.getXMLWait();
var group = ajax.getAnswer();
alert(group);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2016 06:52 AM
Sadly, it doesn't work !
Maybe it has something to do with me using Customer Services application ? .. Should the script include be in global to be called asynchronously ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2016 07:23 AM
Here's my script include, which works perfectly with an async call
var GetAssignementGroup = Class.create();
GetAssignementGroup.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
type: 'GetAssignementGroup',
getGroup: function()
{
var groupMember = new GlideRecord('sys_user_grmember');
//Get the type sys_id
var groupType = new GlideRecord('sys_user_group_type');
groupType.addQuery('name', 'Affectation RCBT');
groupType.query();
groupType.next();
groupMember.addQuery('group.type','CONTAINS', groupType.sys_id);
groupMember.addQuery('user', gs.getUserID());
groupMember.query();
if(groupMember.next())
return groupMember.group.sys_id;
else
return null;
}
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2016 07:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2016 07:39 AM