Update a RITM variable field via an approval comment in an email

Bidduam
Tera Guru

So I have a catalog item that has a flow that once the Request and RITM is logged an approval is sent the a manager.

 

The manager has a link in the approval email that when they approve a email reply template is generated with an obvious spot for them to add a reply message.

What I want to do is have the email read upon reply, extract a particular part of the email out and update a variable that is on the RITM that is associated with the approval that was replied to.

So for example:

REQ00110011

    >> RITM110001

         >> APPROVAL - Manager approval email

            >> Manager responds via the approval email

>> inbound Action to extract the response from the body of the email (not the entire body preferably) and updates a variable called "u_manager_response" on the RITM (RITM110001)

 

Anyone know how this is possible to achieve?

1 ACCEPTED SOLUTION

Bidduam
Tera Guru

Thank you @Mark Manders & @Ankur Bawiskar thank you both for you help.

Ultimately I have created an Inbound email flow and added a custom action of mine to update the variable value that I wanted to add the email body text extract to and wrote a script to extract the text.

I've added a | to the start of the text area I want and the same | to the end and the following script extracts what is between the |   |

var input = fd_data.trigger.body_text;
var parts = input.split("|");
var result = parts.length > 1 ? parts[1].trim() : "";
return result;

 

I totally understand that users sometimes don't follow basic instructions and this ultimately may not be the final solution, but we will test it and see how it goes.

Thanks again to both of you for trying to help - it certainly put me on the right path.

View solution in original post

5 REPLIES 5

Mark Manders
Mega Patron

Use an inbound flow and get the information from the email. How you do that, depends on how the email is formatted.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

@Mark Manders ok thanks for the idea.

 

As far as extracting the text that I want, all text will be between two lines in the body of the email.

 

The lines are just a heap of dashes eg: --------------- I'll want everything between the last dash on the first line of dashes and the first dash on the last line of dashes.

 

Any ideas for that please?

 

EG:

Some text here

and maybe some more

----------------------------------------

I want to extract all of the text

that I have here

between the lines

----------------------------------------

You can use regex to do that, but do know that you are relying on the content of the email body that is filled and send by a person. People tend to make mistakes 😉

 

You can try with this regex:

---------\s*([\s\S]*?)\s*---------


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Ankur Bawiskar
Tera Patron
Tera Patron

@Bidduam 

you can use inbound flow or inbound email action and handle this

you will have to perform some string manipulation to extract the value from email body

use this and enhance for your requirement

Easiest way to Trigger Catalog Item Request via Inbound Email 

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