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

How to add an array to List field type

Alon Grod
Tera Expert

Im trying to add all the groups of specific user to a List field type called Groups.

What am I doing wrong?


4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Alon Grod 

do this while pushing into array

arr.push(gr.group.toString());

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Alon Grod 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Weird
Mega Sage

I'd recommend avoiding taking photos and instead just post the code directly so it's easier to see.

But from what I can read from the photo's, it looks like on your client script you have "ans = and" on line 17.
Perhaps it's supposed to be ans = ans.

Also when using while loops for GlideRecord it's a good idea to use something like toString to make sure you're not including a reference to an object. For example in the script include I'd change arr.push(gr.group) to arr.push(gr.getValue('group')). (Or gr.group.toString() works as well)

Muhammad Hamza
Kilo Sage

What you can do is use:

arr.push(gr.getValue("group")); // will give you the sys_id of the group

arr.push(gr.getDisplayValue("group")); // will give you the display value of the group that is visible on the forms

 
If this answers your question and solves your problem, kindly mark this answer as the solution.