- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2020 08:01 AM
How can I add the email address of an external user to the watchlist as soon as a ticket is created by email? I don't want to create an account for every single external user automatically, which is why the caller field gets set to the guest account. I'm open to creating a new field so that the external user email address gets added. My goal is to automate this because I want to be able to send an email to the external address without having to copy and paste the email address to the watchlist field every time.
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2020 10:58 AM
UPDATED: I used the following code to not exclude internal users on the inbound action.
//code if it's guest account, include everyone on watchlist
if (current.opened_by.name.toLowerCase() == 'guest'){
current.watch_list = (email.recipients + "," + email.origemail);
} else {
//code to not exclude on watchlist when it's an internal user
current.opened_by == 'sys_user';
current.watch_list = email.recipients;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2020 08:08 AM
Add below code right before current.insert on our inbound action.
// Add All Email Recipients to Watch List
var wList = current.watch_list;
var rarray = email.recipients_array;
var instanceEmail = gs.getProperty('glide.email.user');
var ignoredEmail = instanceEmail;
var ignoredEmailArray = ignoredEmail.split(',');
for (var i = 0; i < rarray.length; i++) {
var recipient = rarray[i];
//Check to see if it's a user address
var gr = new GlideRecord('sys_user');
gr.addQuery('email', recipient);
gr.query();
if (gr.next()) {
// It's a user
if (wList != "") {
wList = (wList + "," + gr.sys_id);
} else {
wList = gr.sys_id;
}
} else {
//It's not a user either...so just add the address to the list...except instance email address
if (!new ArrayUtil().contains(ignoredEmailArray, recipient)) {
if (wList != "") {
wList = (wList + "," + recipient);
} else {
wList = recipient;
}
}
}
}
current.watch_list = wList;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2020 10:04 AM
Hi Mike,
I used part of your code to help me figure this out using the following code. This seemed to work for me, thanks for your help.
if (current.opened_by.name.toLowerCase() == 'guest'){
current.watch_list = (email.recipients + "," + email.origemail);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2020 10:58 AM
UPDATED: I used the following code to not exclude internal users on the inbound action.
//code if it's guest account, include everyone on watchlist
if (current.opened_by.name.toLowerCase() == 'guest'){
current.watch_list = (email.recipients + "," + email.origemail);
} else {
//code to not exclude on watchlist when it's an internal user
current.opened_by == 'sys_user';
current.watch_list = email.recipients;
}