Inbound email flow

pratiksha5
Mega Sage

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.

6 REPLIES 6

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @pratiksha5 

 

Have a look here

 

https://www.servicenow.com/community/developer-forum/inbound-email-action-auto-populate-values-in-in...

*************************************************************************************************************
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]

****************************************************************************************************************

Amit Pandey
Kilo Sage

Hi @pratiksha5,

 

Please use the following code in your inbound action script-

var assignTeam = email.body.assignment_group.trim();
current.setDisplayValue('assignment_group', assignTeam);

getting email is undefined.  I have tried below and it is not working as well

var assignTeam = fd_data.trigger.body_text.assignment_team.trim();

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.