Auto Assigning incident Based on Email body Keywords to Assigned to
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2024 11:32 PM - edited 05-23-2024 12:44 AM
Hi All
I am trying to Assign the incident to Assigned to
let say in email body @XYZ look in to maintenance which creates an incident Assigned to xyz
in my condition Inbound actions
here in the incident configured that based on caller location is auto populated and based on location Assignment group would be auto-populated my requirement that in the body updates like Hi @xyz desk light not working please look in to it So that Assigned to auto update to xyz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 10:33 AM - edited 05-24-2024 10:36 AM
Hi @manumanoj ,
You can get the email body, use the below script :
Please refer to the article for a detailed step by step guidance :
https://www.servicenow.com/community/developer-forum/how-to-trim-data-from-received-email-s-body/m-p...
Please accept solution ✅& 👍Helpful if it helped answer your query.
Thanks,
Mahathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2024 08:57 PM
Hi @Mahathi
Can you please more specific on the this
for example email body : Hi @xyz issue with Adobe software Please look in to it
it has to assigned to xyz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 07:44 AM
Hi @manumanoj ,
You can try something like below:
var emailBody = email.body_text;
// Find the word "hi" and get the substring after it
var hi = emailBody.toLowerCase().indexOf("hi");
if (hi!== -1) {
var afterHi = emailBody.substring(hiIndex + 2).trim();
// Extract the username or email from the remaining string
// Assuming the format is "hi username" or "hi user@example.com"
var usernameOrEmail = afterHi.split(" ")[0];
// Query the sys_user table for the user
var userGR = new GlideRecord('sys_user');
userGR.addQuery('user_name', usernameOrEmail).addOrCondition('email', usernameOrEmail);
userGR.query();
// Check if the user exists
if (userGR.next()) {
var userSysId = userGR.sys_id;
// Update the "Assigned to" field in the incident
current.assigned_to = userSysId;
current.update();
}
}
Check what will be displayed, the username or email and modify the code accordingly.
Please mark helpful and accept as solution if this helped answer your query.
Thanks,
Mahathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2024 04:16 AM
@manumanoj : Any luck?