- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2022 04:50 AM
Hi all,
I`m trying to implement a client script to fill in the into the watchlist field "u_rta" using the setValue() function. I can do it with one user but I don´t know how to fill the field with another 2 fields.
I need something like: g_form.setValue('Watch_List', user1,user2,user3);
I have implemented the following code:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
g_form.setValue('Watch_List_email', "");
g_form.setValue('Watch_List', "");
if (newValue == '5ebd8536db94c4949f43ff361d9619a7') {
var grCCS = new GlideRecord('cmdb_ci_service');
if (grCCS.get('5ebd8536db94c4949f43ff361d9619a7')) {
g_form.setValue('Watch_List', grCCS.u_rta);
}
}
}
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 02:39 AM
Finally solved my issue with the following syntax:
g_form.setValue('Watch_List', app.u_gta + ',' + app.managed_by + ',' + app.u_rsa_backup);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2022 05:42 AM
Hi Hitoshi,
I just tried this:
g_form.setValue('Watch_List', 'grCCS.u_gta,grCCS.managed_by,u_rsa_backup');
grCCS.u_gta contains the sys_id.
It doesn´t work for me:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2022 06:52 PM
Hi,
Need to remove the single quote.
Does sys_id of each of grCCS.u_gta, grCCS.managed_by, and u_rsa_backup contain a sys_id? If so, try the following.
Is the watch list variable name "Watch_List" with upper case "W" and "L"? OOTB, it's "watch_list" with all lowercase.
g_form.setValue('Watch_List', grCCS.u_gta + ',' + grCCS.managed_by + ',' + u_rsa_backup);
Finally, check the post after posting a reply to see if the content is correctly displayed. It is necessary to save an image to local pc and then attach it to the post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 01:25 AM
Hi,
The variable name "Watch_List" is correct.
I have tested your code but still not working.
As you can see on the next image, grCCS.u_gta contains the sys_id of the user.
If I add only one user, it works.
g_form.setValue('Watch_List', grCCS.u_gta);
Sorry for the issues with the images on the previous response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2022 05:10 AM
Hi,
As mentioned by Hitoshi you need to set comma separated sysIds and it would work
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
‎07-05-2022 02:39 AM
Finally solved my issue with the following syntax:
g_form.setValue('Watch_List', app.u_gta + ',' + app.managed_by + ',' + app.u_rsa_backup);