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 selected values in to "description" field

keerthilatha
Tera Expert

Hi Team,

I have to show record producer-list collector selected values in to "description" field on the table. i have written below code on record producer script cell. please correct me if any wrong here. because it is not working as expected

var myList = g_form.getValue('u_include_all_worker_locations_select_co');

var myArray = myList.split(',');

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

        var gr = new GlideRecord('core_country');

        if (gr.get(myArray[i])) {

                  // Do what you want to the retrieved record

v_desc += '\nSelected Countries to include :'+ producer.u_include_all_worker_locations_select_co;

        }

}

1 ACCEPTED SOLUTION

Edit :




var myList = producer.u_include_all_worker_locations_select_co.toString();


if(myList !='') {


var myArray = myList.split(',');


var str='';


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


        var gr = new GlideRecord('core_country');


      if (gr.get(myArray[i])) {


str += 'Selected Countries to include :'+ gr.name ;



        }


}


current.v_desc =str;


}


View solution in original post

21 REPLIES 21

yes divya i tried, this but it is not working


var myList = producer.u_include_all_worker_locations_select_co.toString();


var myArray = myList.split(',');



var desc =" ";


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


        var gr = new GlideRecord('core_country');


      if (gr.get(myArray[i])) {


v_desc += '\nSelected Countries to include :'+ gr.name;


        }


}


alert(Answer) ;


You need to write v_desc += '\nSelected Countries to include :'+ gr.name; above alert adn after the 2 "}"


If you're copying to a string field you should just be able to use the below:



current.v_desc += producer.u_include_all_worker_locations_select_co.getDisplayValue();


i need to populate name, in this values are showing in list collector


find_real_file.png


divya mishra
Tera Guru

Hey Keerthi,



Could you please try the below :



var collectorName = 'u_include_all_worker_locations_select_co';


var myListCollector = g_list.get(collectorName);


var selectedOptions = g_form.getValue(collectorName).split(',');




Now you can access any values here by selectedOptions[0]........upto selectedOptions.length value




Let me know if this was helpful/correct


Have a lovely day ahead




Regards,


Divya Mishra