Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Nana5
Mega Guru

Hi Please find some example below:


var list = current.watch_list.getDisplayValue();


  var array = list.split(",");


  for (var i=0; i < array.length; i++) {


    gs.print("Display value is: " + array[i]);


  }



Thanks



hi prakash,


is this in client script


Hi


Current you can use in client script.Try using in business rule..



Thanks


Sorry.i mean to say current object u will not able to use in client script so try with Business rule.


Thanks


Use before update BR and below BR can be little help :


-------------


var glist = current.u_select_locations_to_include.toString();


var arr = glist.split(",");


var str = "";


for(var i=0; i<arr.length; i++)


{


var gr = new GlideRecord("u_custom_workforce_report_request");


gr.query("sys_id",arr[i]);


gr.query();


if(gr.next())


{


if(str.indexOf(gr.field_name) == '-1')


{


str += gr.field_name; // field_name is what value you need from the table


}


}


}


current.string_field = str;


------------------------