- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 03:05 AM
Hi all,
I've seen posts from the past, but maybe something changed in the meantime: Are there any new solutions for parsing name:value pairs in inbound mail bodies which are supposed to be handled by an inbound mail triggered Flow instead of a classic Inbound Action?
Best regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 12:39 AM
Thanks a lot for helpful answers. Eventually, I solved it using a custom action which can parse any input dynamically.
Snippet:
var reg = inputs.bodyText.split(/\r\n|\r|\n/); // reg becomes an array.
var parsedObj = {};//split into 2d array
for(var i=0;i<reg.length;i++){
reg[i] = reg[i].split(":");
parsedObj[reg[i][0]]=reg[i][1];
}
It returns an object where I can access any of the parameters with a simple dot walking because the key is also the name of the parameter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 03:17 AM
Hi @Stefan Reichelt ,
You can take help from this thread by referring Robert's video : https://www.servicenow.com/community/developer-forum/parsing-email-body-with-inbound-email-flows/m-p...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 03:33 AM - edited 02-01-2023 03:33 AM
Hi! @Stefan Reichelt You can try with below script -
gs.log("Values are "+email.body.corrective_action_follow_up+"---"+email.body.first_response_corrective_action);//check the actual values in the 1st line of inbound action
if (email.body.corrective_action != undefined){
current.u_first_response_corrective_action = email.body.first_response_corrective_action;
}
if (email.body.suspected_cause != undefined){
current.u_suspected_cause = email.body.suspected_cause;
}
if (email.body.corrective_action_follow_up != undefined){
current.u_corrective_action_follow_up = email.body.corrective_action_follow_up;}
Please mark it helpful if it helps..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 05:19 AM
Hi Sonia,
I want to achieve it within a Flow that is using the Inbound Mail trigger, not a classic Inbound Action. Do you think it's still achievable like this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 05:44 AM
Hi! @Stefan Reichelt
With Inbound Actions you could use something like "current.body.number", "current.body.something", to get the value on a line in your email body after for example "Number: ", "Something: ", etc..
I achieved this with Inbound Email Flows using below example-
fd_data.trigger.body.number;
fd_data.trigger.body_text.number;
Only this just returns null.
Please mark helpful if it helps...