- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2025 03:42 AM
I have created this email script to add the recipients in cc however it is working for custodian l4 name which is a reference field but not working for reviewers (which is list collector type) and another field u_corp_cert which is also a reference field. pls let me know the issue as script is same but not working for list collector & reference field as they are referencing to User Table
Here is the code
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2025 03:50 AM
Hello @Naman Jain2412
if (current.reviewers) {
var reviewersArray = current.reviewers.toString().split(',');
for (var i = 0; i < reviewersArray.length; i++) {
var userGr = new GlideRecord('sys_user');
if (userGr.get(reviewersArray[i]) && userGr.email) {
email.addAddress('cc', userGr.email.toString(), userGr.getDisplayValue());
}
}
}
Use the above code for reviewers. The reason behind the failure of code is -
-
This is a multi-value field that contains multiple users, stored as a comma-separated list of sys_ids — not GlideRecord references.
-
So
current.reviewers.email
won’t work — becausereviewers
is not a single record.
Pls mark my solution as accept and thumbs up if you find it helpful. It will help other users on community to find helpful response.
Regards,
Samaksh Wani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2025 03:45 AM
Hi,
For list fields, add a for loop
var reviewers = current.reviewers.toString().split(','); // Get sys_ids as an array
for (var i = 0; i < reviewers.length; i++) {
var userGR = new GlideRecord('sys_user');
if (userGR.get(reviewers[i])) {
email.addAddress('cc', userGR.email, userGR.getDisplayValue());
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2025 03:50 AM
Hello @Naman Jain2412
if (current.reviewers) {
var reviewersArray = current.reviewers.toString().split(',');
for (var i = 0; i < reviewersArray.length; i++) {
var userGr = new GlideRecord('sys_user');
if (userGr.get(reviewersArray[i]) && userGr.email) {
email.addAddress('cc', userGr.email.toString(), userGr.getDisplayValue());
}
}
}
Use the above code for reviewers. The reason behind the failure of code is -
-
This is a multi-value field that contains multiple users, stored as a comma-separated list of sys_ids — not GlideRecord references.
-
So
current.reviewers.email
won’t work — becausereviewers
is not a single record.
Pls mark my solution as accept and thumbs up if you find it helpful. It will help other users on community to find helpful response.
Regards,
Samaksh Wani