- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2017 02:36 AM
Hello All,
var dept_list = [];
var str;
var bu = new GlideRecord('u_salesforce_access');
bu.addQuery('u_division',div);
bu.query();
while (bu.next()){
uniqueMembers.push(bu.u_bu.toString());
}
var arrayUtil = new ArrayUtil();
dept_list = arrayUtil.unique(uniqueMembers);
i have the dept_list values correct and displaying in log as
I need to return these choices to the client script GlideAjax and from the client script i need to populate each option as a dropdown for select box data type in our catalog item
Could you please help me with the code to return these choices to client script and make it populate for a drop down field
Rajesh
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2017 03:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2017 02:43 AM
Make a for loop and use the addOption sysntax to achivee this one.
call the ajax call script,
var ga = new GlideAjax('script include name');
ga.addParam('sysparm_name','script include function name');
ga.getXML(choices);
function choices(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
for (var i =0; i<answer.length:i++){
g_form.addOption('fieldname',answer [i],answer[i]);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2017 02:43 AM
Hi Rajesh,
Have you used return in the function . Use return dept_list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2017 02:54 AM
Hello All,
I have used return funtion also , but i was getting an error like messgae
I think its not returning the correct value because dept_list is an array decalaration , so iam not able to fetch the options from the client side
I need how to return the options , Iam using an array in my script but that's not working
my question is how do i return the options to client side
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2017 03:02 AM
Try this function,
var dept_list = [];
var str;
var bu = new GlideRecord('u_salesforce_access');
bu.addQuery('u_division',div);
bu.query();
while (bu.next()){
dept_list .push(bu.u_bu.toString());
}
var arrayUtil = new ArrayUtil();
dept_list = arrayUtil.unique(dept_list .toString());
return dept_list;