- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2018 05:48 PM
Hi all,
finding this oddly frustrating...I've got a GlideAjax calling a script include to look up the sys_user_delegate table and return values based on the GlideRecord to populate a read only field on a form, and remove duplicates before sending back.
anyone see what's wrong with this script? thanks!
Script include:
var AjaxGetDelegates = Class.create();
AjaxGetDelegates.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getDelegates:function(){
//var delList = [];
var user = this.getParameter('sysparm_user');
var delegates = new GlideRecord('sys_user_delegate');
delegates.addQuery('user',user);
delegates.query();
var delList = [];
while(delegates.next()){
var dels = delegates.delegate; //field on the delegate table I want to return
delList.push(dels);
//delList = delList + delegates.delegate+',';
}
var arrayUtil = new ArrayUtil();
delList = arrayUtil.unique(delList);
return delList;
}
});
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2018 06:22 PM
If you can even mention your client script code that would be a bit more helpful
Thanks,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2018 06:30 PM
Hi Siva,
here's the client script:
function onLoad() {
//look up sys_user_delegate table and populate "my_delegates" field
var user = g_form.getValue('current_user');
var gr = new GlideAjax('AjaxGetDelegates');
gr.addParam('sysparm_name','getDelegates');
gr.addParam('sysparm_user',user);
gr.getXML(setDelegates);
//populate the my_delegates field
function setDelegates(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
alert('answer is '+answer);
if(answer == '' || answer == undefined){
return false;
}else{
var arr = answer.split('||');
if (window === null)
g_form.setValue('my_delegates',arr);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2018 06:31 PM
Just after running an initial run in Background script i think the issue you are facing is getting a single sys id in your result if i am not wrong
Just modify your code a little bit as below
var dels = delegates.delegate.toString(); //field on the delegate table I want to return
and that should work
i have run this in my background script and its working
var delList = [];
while(delegates.next()){
var dels = delegates.delegate; //field on the delegate table I want to return
delList.push(dels);
//delList = delList + delegates.delegate+',';
}
var arrayUtil = new ArrayUtil();
delList = arrayUtil.unique(delList);
return delList;
}
Hope this helps
Mark this response as correct if that resolves your query
Thanks,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2018 06:47 PM