- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2023 11:53 AM
I have created a flow that generates an incident from email. The email that triggers the flow is from a generic service account in our environment but in the email body, the user's email will be populated. In theory, I should be able to pull the user_name from that. How would I script that? This process is in flow designer.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2023 03:47 AM
Hi @Wyatt Fudal1 ,
In a normal Inbound email action , we can get the email id using redux to the email body in action part, where we can script. Using this ,we can save it a variable and initilaize an incident.
But in a flow, I think we have to create flow action, where we get the output as email id. Then we can use it in the flow designer. Adding the code for getting sysid of the user to create incident.
(function execute(inputs, outputs) {
// ... code ...
var shortDesc=inputs['EmailBody'];
function extractEmails ( shortDesc ){
return shortDesc.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)/gi);
}
var user_email_id = extractEmails( shortDesc );
var userid=new GlideRecord ('sys_user');
userid.addQuery('email',user_email_id);
userid.query();
if(userid.next()){
var id =userid.getUniqueValue();
}
outputs ['id']=id; //you can get email id of user using this by using user_email_id as output
})(inputs, outputs);
Please verify this. Will add some screenshots .Please try.
Thankyou,
prithvi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2023 03:47 AM
Hi @Wyatt Fudal1 ,
In a normal Inbound email action , we can get the email id using redux to the email body in action part, where we can script. Using this ,we can save it a variable and initilaize an incident.
But in a flow, I think we have to create flow action, where we get the output as email id. Then we can use it in the flow designer. Adding the code for getting sysid of the user to create incident.
(function execute(inputs, outputs) {
// ... code ...
var shortDesc=inputs['EmailBody'];
function extractEmails ( shortDesc ){
return shortDesc.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)/gi);
}
var user_email_id = extractEmails( shortDesc );
var userid=new GlideRecord ('sys_user');
userid.addQuery('email',user_email_id);
userid.query();
if(userid.next()){
var id =userid.getUniqueValue();
}
outputs ['id']=id; //you can get email id of user using this by using user_email_id as output
})(inputs, outputs);
Please verify this. Will add some screenshots .Please try.
Thankyou,
prithvi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2023 11:36 AM
Thank you that worked.