Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to assign multiple values to a list field

sk59
Tera Expert

Hi,

I am getting some list of ID's by querying a table, now i need to assign all those ID's to a list field.

Please let me know how can i achieve this.

Thanks in Advance

1 ACCEPTED SOLUTION

you need to do it like this



var arr = [];


var allChildRecords = new GlideRecord('sc_request');


  allChildRecords.addQuery('parent', parentSysId);


  allChildRecords.query();


  while(allChildRecords.next()){


        arr.push(allChildRecords.getValue('sys_id'));


      }



current.list_field = arr.join(',');


View solution in original post

5 REPLIES 5

larstange
Mega Sage

Hi



A list field is just a comma separated string of sys_ids for records in the table which the list is pointing to.



So if you have your IDs in eg. an array you can say



current.list_field = array.join(',');


Sharique Azim
Mega Sage

Hi Sk59,



If the field is belonging to the same table from which you have gathered the sys_id. You can simply set the field with that variable then.



say your sys_id are stored in var a, which was an array, you can use something like a.join(',');


then simply you can set the field to   current.list_field=a; //server side,   use g_form for client script.


var allChildRecords = new GlideRecord('sc_request');


  allChildRecords.addQuery('parent', parentSysId);


  allChildRecords.query();


  while(allChildRecords.next()){


var ID = allChildRecords.u_id;


         


      }




In the above code I am getting multiple id's in ID. I need to assign these ID's into a list field(say   'abc') in a different table (say change table)


Hi Sk59,



I am skeptical about you getting the results   like that. Please employ array to store   sys_id.



Reference qualifier on catalog item using script include to exclude records dynamically   deals with a similar issue, please refer to the answer made by chuck or the correct answer.



Dont forget to mark the answer correct or helpful,if it helps