How to set multiple values in List Collector Variable using Script ?

Ayushi1
Tera Contributor

Hi All,

I have one Variable which is referring to the sys_user table and when that variable is set then i need to auto-populate the users groups in the list collector variable.

Please help me to set the groups of user in the list collector variable. 

 

1 ACCEPTED SOLUTION

Alikutty A
Tera Sage

Hi Ayushi,

You could set the glide_list attribute on the List collector to make it behave like a normal platform List field. Once the attribute is set, you can set comma separated sys_id's of users directly using g_form.setValue('') without any complex scripting in it. Also it will work on service portal as well.

ie g_form.setValue('list_field' , '1,2,3,4,5'); // comma separated sys_id's of user.

Refer https://docs.servicenow.com/bundle/newyork-it-service-management/page/product/service-catalog-manage...

Thanks!

View solution in original post

6 REPLIES 6

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

check here:

https://community.servicenow.com/community?id=community_question&sys_id=45168b61db1cdbc01dcaf3231f96...

If I have answered your question, please mark my response as correct and/or helpful.

Thank you very much

Cheers
Alberto

Alikutty A
Tera Sage

Hi Ayushi,

You could set the glide_list attribute on the List collector to make it behave like a normal platform List field. Once the attribute is set, you can set comma separated sys_id's of users directly using g_form.setValue('') without any complex scripting in it. Also it will work on service portal as well.

ie g_form.setValue('list_field' , '1,2,3,4,5'); // comma separated sys_id's of user.

Refer https://docs.servicenow.com/bundle/newyork-it-service-management/page/product/service-catalog-manage...

Thanks!

Hi Alikutty,

 I have used same one it is not working in portal.Any suggestion,please let me know.

 

Thanks,

Pavani.

asifnoor
Kilo Patron

Hi,

You would need a reference qualifier and a Script Include.

The SI shall take the user, read the table sys_user_grmember and fetch the groups associated to this user and return back.

Ref: https://community.servicenow.com/community?id=community_article&sys_id=f3663ed6db8a7b002e8c2183ca961...

Mark the comment as a correct answer and helpful if this helps.