Populate a list field from a client script

Flavio Tiezzi
Kilo Sage

Hello all,

From a client script of a UI Page I need to put the sys id of the users that I got in the modal into a list field. I'm getting the values, as shown in the screenshoot below. But when trying to put the values inside the list field, it remains empty.

find_real_file.png

 

find_real_file.png

    var notes = gel('notes').value;
    var user = gel('users').value;

	
    g_form.setValue('field1', user); // remains empty
    g_form.setValue('field2', notes);

 

2 REPLIES 2

sachin_namjoshi
Kilo Patron
Kilo Patron

List needs , separated sys_id values.

You will need to push array values like below

 

https://community.servicenow.com/community?id=community_question&sys_id=483370c4db1c3b04feb1a851ca9619a4

 

Regards,

Sachin

But wouldn't I be able to do this directly in the client script?

Because I need to put this value in a list field on the form. In the case of field2, it worked to put it using g_from.setValue()