Inbound action with data in sperate line

samadam
Kilo Sage

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?

1 ACCEPTED SOLUTION

Juhi Poddar
Kilo Patron

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:

JuhiPoddar_0-1746343095336.png

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

View solution in original post

5 REPLIES 5

Juhi Poddar
Kilo Patron

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:

JuhiPoddar_0-1746343095336.png

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