- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2025 11:55 AM
I have an inbound email that is coming with data in separate line, As is email actions are not creating and updating the fields. How can I parse this?
Type:
Test Type
Date:
02-03-2025
Any idea how to get this working?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2025 12:27 AM
Hello @samadam
Here is the script you can try:
var body = "Type:\nTest Type\nDate:\n02-03-2025";
//var body = email.body_text;
function extractValue(label) {
var pattern = new RegExp(label + ":\\s*([\\s\\S]*?)(\\n[A-Z][^:]*:|$)", "i");
var match = pattern.exec(body);
return match ? match[1].trim() : "";
}
var testType = extractValue("Type");
var testDate = extractValue("Date");
// Log values for debugging
gs.info("Email Body:\n" + body);
gs.info("Parsed Type: " + testType);
gs.info("Parsed Date: " + testDate);
Result:
Note: Modify the script as needed for use in your Inbound Email Action.
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2025 12:27 AM
Hello @samadam
Here is the script you can try:
var body = "Type:\nTest Type\nDate:\n02-03-2025";
//var body = email.body_text;
function extractValue(label) {
var pattern = new RegExp(label + ":\\s*([\\s\\S]*?)(\\n[A-Z][^:]*:|$)", "i");
var match = pattern.exec(body);
return match ? match[1].trim() : "";
}
var testType = extractValue("Type");
var testDate = extractValue("Date");
// Log values for debugging
gs.info("Email Body:\n" + body);
gs.info("Parsed Type: " + testType);
gs.info("Parsed Date: " + testDate);
Result:
Note: Modify the script as needed for use in your Inbound Email Action.
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar