We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

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!

1 ACCEPTED SOLUTION

@MartinV 

this is some other error about invalid HTML

see these links

Email validation failed: Email body comprised of invalid HTML 

Send email Action in flow designer fails with the error "Email validation failed: Email body is comp... 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

8 REPLIES 8

namanajain
Mega 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

Hi @MartinV 
This is the action I made to fetch the work_notes for WOT through sys_journal_field. After adding this action in the flow u can directly use this output . 

namanajain_0-1777542237070.png

OUTPUT:-

namanajain_1-1777542405550.png

 

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

If my answer has helped with your question, please mark my answer as accepted solution.

Thank you

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