- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2022 02:22 AM
Hello!
I have a catalog item with a list collector variable.
I want to populate this variable with specific users (ex. User A, User B, User C). I've tried using the below (Catalog Client Script) using system properties but it does not work.
function onSubmit() {
g_form.setValue('list_collector_variable', 'sysprop_sysid1, sysprop_sysid2, sysprop_sysid3');
}
Please help!
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2022 02:35 AM
store the comma separated sysIds in system property and use it
javascript: gs.getProperty('propertyName');
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2022 02:57 AM
Hi,
then why not set based on Change of variable instead of onSubmit?
where are you running this script? Native OR Portal
for portal it should work on change of variable
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2022 03:39 AM
Have you considered Catalog Data Lookup Rules? The same can be obtaines with no code at all:
As soon as someone selects the right reference, the system fetches the data and places it into list_collector_variable.
E.g. I have created table u_dl_location_users extending Data Lookup Matcher Rules (so it will be license "free"):
I have added two records:
Have configured the lookup rules:
This tells the system that whenever variable location can be located in column u_location in the lookup table, it should take the value of field u_user and place it into variable users. Yeah, calling a target source variable, is confusing.
Under the circumstances, if one chooses "Washingtom D.C." as location, the user list is automatically filled in by the system:
If the other location is chosen, the matching user list is filled in:
A bit more work upfront (have to create a table and configure data lookup), but easy to maintain.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2022 02:39 AM
Hi Ceraulo,
Having a default value is a better approach as you are using it just before the submission.
To your client script you can update it as below to make it work.
function onSubmit() {
var arr = [];
arr = 'sysprop_sysid1, sysprop_sysid2, sysprop_sysid3'
g_form.setValue('list_collector_variable',arr.toString);
}
Regards,
Deepankar Mathur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2022 02:47 AM
Hi,
You cannot access system property directly in client script, your would need to get those values through GlideAjax.
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP