Auto Populate Email In Watchlist
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2022 01:53 AM
HI Team,
I need an Email ID to be auto populated into watchlist when a particular priority and assignment group were selected.
I have tried using business rule with Before and Insert &Update.
But the Issue is I am getting the email id populated for multiple times when Incident is updated.
var email = " ";
var wl = current.watch_list;
if (current.watch_list.indexOf(email) > -1) {
return;
}
if (current.watch_list == "") {
current.watch_list = email;
} else if (current.watch_list == email) {
return;
} else
current.watch_list += "," + email;
Any kind of help would be grateful
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2022 02:02 AM
Hi @Priya1111
To get assignment group users try below BR
Script :-
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var grpMembers = new GlideRecord("sys_user_grmember");
grpMembers.addQuery("group", current.assignment_group);
grpMembers.query();
while (grpMembers.next()) {
var user = (',' + grpMembers.user);
current.watch_list += user;
}
})(current, previous);
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2022 02:08 AM
Thanks for the reply!
But I need an Email which is not in user table to be auto-populated into watchlist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2022 02:12 AM
Hi @Priya1111 ,
From where you are getting email list? also is it comma separated list?
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2022 02:17 AM
I need only one email to be auto populated into watchlist without creating duplicate entries when updated multiple times.
I have taken as var email = " example@abc.com"; in this way.