We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to get list collector values and populate in string field

keerthilatha
Tera Expert

Hi Team,

I have to get list collector values and populate in string field in other table how can i achieve it.

16 REPLIES 16

sandeep kumar15
Kilo Explorer

(function executeRule(current, previous /*null when async*/ ) {

var list1 = current.u_user_list;
var listlist1=list1.split(',');
for(var i=0;i<listlist1.length;i++){
var gr=new GlideRecord('incident');

gr.addQuery('sys_id',listlist1[i]);
gr.query();
while(gr.next()){
var grr=new GlideRecord('problem');
grr.initialize();
grr.short_description=gr.short_description;
grr.assignment_group=gr.assignment_group;
var id=grr.insert();

gs.addInfoMessage(id);

}

PriyankaC
Mega Expert

For the original question: How to get the list collector values into a string field this is sufficient: 

var stringField = current.watch_list.getDisplayValue();