Parsing Email body in flow designer OOTB

TylerJ333505898
Tera Contributor

I recently tried to use OOTB functionality in flow designer but i cant see to get the values im looking for into my catalog variables. 

I have a trigger condition for a inbound email in flow designer

I then try to submit a catalog item and populate variables but it always returns false instead of the values. 

TylerJ333505898_0-1734443706470.png

  Below is what it appears like in the description of the RITM when i put the body into the description. 

 

Person Number 604731

Effective 12/31/24

Termination Details

Name

Sean Connery

Legal Employer

Spy Corporation

Notification Date

12/16/24

Termination Date

12/31/24

Revoke User Access

After termination

Recommended for Rehire

Yes

Approvers

12/17/24 6:56 AM
Approved by Workflow System

12/17/24 6:56 AM
Submitted by John Smith

Can i pull the date into the term date variable? i tried a few ways and still no luck 

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@TylerJ333505898 

seems your email body has the date on next line

are you using a custom action to parse and get because I could see the Transform function

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Its not a custom script The parse action is there i tried using this but it didnt work either. The format of the email cant be changed so im stuck trying to figure out a solution to this one and im still at a loss trying the parse email body from the community. I do have the parse email body action but i cant get any values from it 

TylerJ333505898_0-1734446528655.png

 


@Ankur Bawiskar wrote:

@TylerJ333505898 

seems your email body has the date on next line

are you using a custom action to parse and get because I could see the Transform function

If my response helped please mark it correct and close the thread so that it benefits future readers.


(function execute(inputs, outputs) {

    /**
     * Strip out HTML and wierdly formatted html.
     */
    function htmlToStr(html) {
        var noHTML = html.replace(/<br(?:\s*)?\/?>/gi, "\n").replace(/(<\/(?:tr|div|p)>)\s*([^\n])/, "$1\n$2").replace(/(<\/(?:td)>)\s*\n/gi, "$1").replace(/(<([^>]+)>)/ig, '');
        return decodeURI(noHTML);
    }



    var logger = new GSLog('', 'Parse Email Body flow action');
    var logLevel = inputs.debug ? "debug" : "info";
    logger.setLevel(logLevel);

    try {

        logger.logDebug("Body Text before cleanup: \n" + inputs.emailBodyText.toString());
        var body_text = htmlToStr(inputs.emailBodyText.toString());
        logger.logDebug("Body Text after cleanup: \n" + body_text);

        var regEx = /^([^:\n\t]+):(.+)$/gmi; //Name is everything preceding first :, value everything after.
        var matches;
        var emailObj = {};
       
        //Process all our matches and add to email object.
        while ((matches = regEx.exec(body_text)) !== null) {
            logger.logDebug("matches: " + JSON.stringify(matches));
            emailObj[matches[1].trim()] = matches[2].trim();
        }


    } catch (ex) {
        gs.error(ex.message);
    }
    outputs.email_var = emailObj; //return parsed name/val pairs
})(inputs, outputs);

@Ankur Bawiskar wrote:

@TylerJ333505898 

seems your email body has the date on next line

are you using a custom action to parse and get because I could see the Transform function

If my response helped please mark it correct and close the thread so that it benefits future readers.




@TylerJ333505898 

seems that's the issue then it looks for the value in same line but the email body has it on new line

did you try to use string manipulation and extract the date and then set?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Not yet, not really sure how to do that as i normally use OOTB if possible. Ill do some research and give that a try thank you sir.