How do I copy values of list collector as alternate values from the same table?

Shane J
Tera Guru

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)?

find_real_file.png

1 ACCEPTED SOLUTION

Sharique Azim
Kilo Sage

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


View solution in original post

5 REPLIES 5

BALAJI40
Mega Sage

You want to convert this list collector values be replace with names in another variable.



If it so, first you need to fetch the options and make a glide record on list collector reference table and push the names of the records.



Try with onChange GlideAjax catalog client script.


I guess Multi line single text is the best option. If you go with again list collector, it needs to above reference table only, but display value is different.


Sharique Azim
Kilo Sage

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


Update:



I also should mention if the field is list collector on the service catalog, simply current=field_name1= current.variable_pool.field_name2.getValue() (of the service catalog ); sets the fields right away.


Well you lost me with this.   I am doing this on the Service Portal.   Can you give me some context?