- 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 04:58 AM
Hello,
You can not set multiple values in watch list.
Regards,
Alok Gupta

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-04-2022 05:04 AM
Hi Hector,
Try setMultipleValues().
Mark Correct or Helpful if it helps.
Thanks,
Yousaf
***Mark Correct or Helpful if it helps.***

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-04-2022 05:08 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-04-2022 05:24 AM
Hi again,
Something like below.
var ciArray = [];
var grCCS = new GlideRecord('cmdb_ci_service');
grCCS.addQuery('name', 'IN', 'SAP Payroll,SAP Labor Distribution'); // change select criteria to fit need
grCCS.query();
while (grCCS.next()) {
ciArray.push(grCCS.sys_id.toString());
}
g_form.setValue('watch_list', ciArray.join(',')); // JavaScript is case sensitive. OOTB field name is "watch_list" with all lowercase letters.