The CreatorCon Call for Content is officially open! Get started here.

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


add your code within the for section



"for section" means


the code that would write within the for loop


I am not clear please help, in edition of above code.



u_select_locations_to_include-My list collecter field name on record producer


u_custom_workforce_report_request- My custom table


u_select_fields_to_be_included_in_the_report-My custom table field where i have to display the selected values in the list collector


This code should work but if you're using a client script you'll need to call this from GlideAjax or a reference qualifier depending on how you're implementing this requirement.



var gr = new GlideRecord('u_custom_workforce_report_request');


var list = producer.u_select_locations_to_include.toString();  


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


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


gr.u_select_fields_to_be_included_in_the_report += array[i];


}  



if you opt to stick it in a business rule running on the u_custom_workforce_report_request table you might have to use



var list = current.variables.u_select_locations_to_include.toString();


lect_locations_to_include


Sharique Azim
Mega Sage

Well list collector stores the sys id , so basically its an advanced form of reference field.


<for server side scripting,else this logic can be used in script include>



store the value in some var arr=   current.list_collector.split(',');


then you can use a for loop get all the values


var   new_arr= []; //empty array



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


gliderecord a table;


gr.addQuery('sys_id', arr[i].toString());


...


....



{


new_arr.push(gr.getValue('name'));


}



}


new_arr.join(',');


another gliderecord;


...


gr1.field_name =new_arr;




<updated,if to be used within record producer>


then just first replace current to producer.