Inbound email flow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2024 09:45 PM
The email body looks like this:
Assignment Team: Win_Infrastructure
I would like to populate the assignment group.
When I am trying to write the script in something like email.body, it is not taking the reference.
Please suggest how to do it. I have multile things to to that's why not using inbound action. If that is not possible, then I will go that way. I'm just trying to see if this can be done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 01:15 AM
Hi @pratiksha5
Have a look here
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 01:24 AM
Hi @pratiksha5,
Please use the following code in your inbound action script-
var assignTeam = email.body.assignment_group.trim();
current.setDisplayValue('assignment_group', assignTeam);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 07:42 AM
getting email is undefined. I have tried below and it is not working as well
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 07:58 AM
Hi @pratiksha5
Alternatively can you try using Flow Designer, with following script-
var emailBody = fd_data.trigger.body_text;
var assignTeam = /Assignment Team\s*:\s*([^\n]+)/i;
var match = emailBody.match(assignTeam);
var assignGroup = match ? match[1].trim() : "Not found";
var assignmentGroup = new GlideRecord('sys_user_group');
assignmentGroup.addQuery('name', assignGroup);
assignmentGroup.query();
if (assignmentGroup.next()) {
return assignmentGroup.sys_id.toString();
} else {
return "No matching record found for contact: " + assignGroup;
}
It had worked for me.