How to push SysIDs in reference field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2023 10:33 PM
Hi Everyone
I have an arrays of sysids in client script and i want to push those sysids in a reference field in that client script. How can i push. Please help..thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2023 12:21 AM
Hi @Maddysunil ,
You can only set only one value to the reference field using g_form.setValue('field_name', <sys_id>);
If you want to set multiple sys_ids, the field should be of type list collector.
If you have sys_ids for different fields in an array, you can use key of array to set the field value.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2023 12:48 AM
Hi @Maddysunil ,
you can not set multiple values on client side. you can multiple values only for list field then use below script.
var users = ['804464ec2fca9810c5a950492799b698', '6816f79cc0a8016401c5a33be04be441'];
g_form.setValue('watch_list', users);
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2023 01:16 AM
Hi Pawan...got your point thanks..so now i m not using that client script , I am using advance reference qualifier now on that reference field and trying to get current page URL on script include side as i need some parameters , Is there any way we can get URL in script include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2023 02:58 AM
Hi @Maddysunil ,
Yes, you can pass current values in script include and set URL on script include itself.
sysid is the key to every record if you pass current sysid and then set url.
Refer below
ServiceNow Community MVP 2024.
Thanks,
Pavankumar