Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Send last comment to email

MartinV
Tera Contributor

Hi, 
I have a flow that sends an email when someone writes a comment in a work order task. I am sending template message with the number of the WOT. When I reply to that email, the text gets sent to the activity of the WOT.

Here is where the problem starts. I tried adding the actual comment to the body of the email via data pill , however the flow returns and error "invalid body html". 
Then I tried a different approach, by adding a custom action with a script step that pulls the comment, but it didn't work either. Is there a way to pull the last message from the activity to the mail body?


The idea of the whole thing, you write a comment in the WOT - a mail gets send to a defined recipient, e.g. a contractor. He sees that message, and replies back via the email. Everything works, except for the comment not being sent. I would appreciate if you point me to the right direction. 

Thanks!

3 REPLIES 3

Ankur Bawiskar
Tera Patron

@MartinV 

share some screenshots

 

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

namanajain
Kilo Guru

Hi @MartinV 

namanajain_0-1777373301162.png

Comments and work notes are not stored directly in the Activity stream. They are actually saved in the sys_journal_field table.
That’s why you need to read from sys_journal_field to get the latest comment or work note and then add that text to the email body.
Try to write the script using this table .
Please like the comment if helpful and if u got your answer please mark it as the solution

Sanjay191
Kilo Patron

Hi @MartinV 

did you try to use the getJournalEntry method to get the latest comments of that Work order task
 var comment = current.comments.getJournalEntry(1);
return comment;

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Thank You