How to create multiple incidents through inbound with multiple recepients?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 09:19 AM
Hi all,
We have 5 emails from different regions.
- assist@reg1.com - Assistreg1 group
- assist@reg2.com - Assistreg2 group
- assist@reg3.com - Assistreg3 group
- assist@reg4.com - Assistreg4group
- assist@reg5.com - Assistreg5 group
For all these mailboxes, we have different assignment groups as well. All the emails auto forwarding is set to ServiceNow. Suppose if a user sends an email to assist@reg1.com then the incident needs to be assigned to Assistreg1 group and if it is send to assist@reg2.com then it needs to be assigned to Assistreg2 group and so on.
Now, if a user sends an email to the above 2(assist1 and assist 2) mail boxes, then 2 incidents should get created to assist1 and assist2 groups. I'm trying to achieve this, Can anyone please guide me on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 09:40 AM
The recipients list is just a comma delimited string. So you can convert that to an array, then loop through the array and create an incident per record like so:
var direct = email.direct; // Assigns the to field, excludes cc field
var groups = direct.split(","); //Convert list of recipients to an array
for(var group in groups) {
var gl = new GlideRecord("sys_user_group");
gl.addEncodedQuery('email=' + group);
gl.query();
if(gl.next()){
current.assignment_group = gl.sys_id;
/*
Fill in the rest of the fields for your record.
*/
current.insert();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 09:45 AM
You should have email rerouting instead of email forwarding, so that an fw is not added to the emails and you know the origin of the email.
Now you need an inbound action if you dont have one already.
Get the email.recipients and split them. For the first one do current.insert(). for the rest of the emails do a GlideRecord and do insert.
Please mark this response as correct or helpful if it assisted you with your question.