Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Select all option in list collector within Service Portal

brianlan25
Kilo Patron

I have a list collector variable with and an Yes/No variable. If the user selects Yes It should select all the values in the list collector. I'm able to do this if the user is not using the Service Portal using Move List Collector Options. Is there a similar script that will work in the Service Portal?

1 ACCEPTED SOLUTION

Naveen20
ServiceNow Employee
The Service Portal list collector is an Angular widget, not the classic slushbucket DOM, so getControl().ms doesn't apply. Instead, set the value directly — g_form.setValue() accepts a comma-separated string of sys_ids.

Try below

Add glide_list=true to the list collector variable's attributes (required for reliable setValue behavior in Service Portal).
Catalog Client Script onChange of the Yes/No variable, applied to both Catalog Item and Service Portal.
On "Yes," call a client-callable Script Include via GlideAjax that returns all sys_ids matching the same query as the list collector's reference qualifier.
Pass the comma-separated result into g_form.setValue(). On "No," clear it.

View solution in original post

1 REPLY 1

Naveen20
ServiceNow Employee
The Service Portal list collector is an Angular widget, not the classic slushbucket DOM, so getControl().ms doesn't apply. Instead, set the value directly — g_form.setValue() accepts a comma-separated string of sys_ids.

Try below

Add glide_list=true to the list collector variable's attributes (required for reliable setValue behavior in Service Portal).
Catalog Client Script onChange of the Yes/No variable, applied to both Catalog Item and Service Portal.
On "Yes," call a client-callable Script Include via GlideAjax that returns all sys_ids matching the same query as the list collector's reference qualifier.
Pass the comma-separated result into g_form.setValue(). On "No," clear it.