- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2017 05:03 AM
I have a List Collector variable in the Service Portal called list1 that customers will populate with whatever number of options. The display names listed make sense to customers, but on the back end our Security group needs to know the value of the actual 'name' field on the reference table instead of what is displayed. See below for an example after submission - the 'Name' is what I need in an alternate field.
So how do I take the value(s) of list1 and convert it into meaningful data in something like a multi-line text field (or another list collector if that's easier)?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2017 05:20 AM
Hi Jude,
The simple answer is to use gliderecord on the particular table, for which the records are been displayed here. As you have mentioned list is used, now the values stored in the selected slush bucket are in sys_id , that means querying that table and asking for the 'name' field simply gives you back the names.
For eg(part of my workflow run script ),
var list=current.field_name;
var lstr =list.toString();
var arr= lstr.split(',');
for(var i=0;i<arr.length;i++){
var temp='';
var grp= new GlideRecord('sys_user'_group);
grp.addQuery('sys_id',arr[i]);
grp.query();
if(grp.next()){
temp=grp.user;
}
current.field_name2=current.field_name2+temp+',';
}
current.update();
Regards,
Shariq
Mark helpful if it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2017 06:17 AM
Nice, thank you!
This worked:
var list=current.variables.list1;
var lstr =list.toString();
var arr= lstr.split(',');
for(var i=0;i<arr.length;i++){
var temp='';
var grp= new GlideRecord('u_cubes_ad_groups');
grp.addQuery('sys_id',arr[i]);
grp.query();
if(grp.next()){
temp=grp.u_name;
}
current.variables.multi_adgroups=current.variables.multi_adgroups+temp+',';
}