Automatically adding users to CC also adds instance mail
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2023 04:34 AM
Hi experts,
we are using code
current.watch_list = current.watch_list + ',' +email.copied;
added to "Create incident" inbound E-Mail action for automatically adding users to the watchlist of the incident.
However, this also adds the instance E-Mail address when users use them to CC the IT Support.
Is there any possibility to make a check in between that IF a specific mail (or more than one) is in CC it will NOT be added to watchlist?
Thank you for helping out!
Regards
Elena

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2023 04:39 AM
Hi @ehgebla,
Try:
var emails = email.copied.split(',');
emails.splice(emails.indexOf('<<emailadress>>'), 1);
current.watch_list = current.watch_list + ',' +emails;
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2023 04:40 AM
Hi @ehgebla
Can you please try the below code .
// Extract the list of CC email addresses from the email
var ccEmails = email.headers.cc; // Assuming "email.headers.cc" contains CC email addresses
// Define the email addresses that you want to exclude from the watchlist
var excludedEmails = ["email1@example.com", "email2@example.com"]; // Add the email addresses you want to exclude
// Check if any of the CC email addresses match the excluded emails
var shouldAddToWatchlist = true;
for (var i = 0; i < ccEmails.length; i++) {
if (excludedEmails.indexOf(ccEmails[i]) !== -1) {
shouldAddToWatchlist = false;
break; // No need to continue checking once a match is found
}
}
// Add the email to the watchlist if it's not in the excluded list
if (shouldAddToWatchlist) {
current.watch_list = current.watch_list + ',' + email.copied;
}
Mark the comment as a correct answer and also helpful if this has helped to solve the problem.
Krishna Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2023 07:01 AM
Hi @Community Alums , Hi @Peter Bodelier
I tested both of your approaches, however I couldn't get it to work with both of them.
When using Peters approach the flow just doesn't execute anymore and doesn't create a ticket. Target record will always be blank.
When using Krishnas approach it will still add the instance mail to the watch list and doesn't exclude them.
Also tried email.copied or email.recipients instead of email.headers.cc.
Regards
Elena

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2023 11:41 PM
Hi @ehgebla,
I assumed there is only 1 email address you need to exclude. Is this correct?
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.