Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

How to send additional comments and work notes in request payload as JSON

Priyadharashin1
Tera Contributor

Hi All,

 

I need the pass as the last additional comment and last updated work notes from Incident Record in the REST action as a payload. I tried using the below scirpt, but it returns the value with the timestamp and user name. If I pass this value in the request body, the JSON becomes invalid.

 

fd_data.trigger.current.comments.getJournalEntry(-1);
 
Could you please provide a solution.
 
Thanks in Advance
Priya
2 REPLIES 2

Harshal Aditya
Mega Sage

Hi Priya,

Please try below code -

var incJson = {
"work_notes":fd_data.trigger.current.work_notes.getJournalEntry(1).match(/\n.*/gm).join("\n"),
"comments":fd_data.trigger.current.comments.getJournalEntry(1).match(/\n.*/gm).join("\n")
}
var res = JSON.stringify(incJson);

 

If my answer has helped with your question, please mark it as helpful and give it a thumbs up!

 

Regards

Harshal

 

Hi Harshal,
 
Thank you.
The below code works:
var comment = fd_data.trigger.current.comments.getJournalEntry(-1).toString().trim().replace(/(\r\n|\n|\r)/gm,"");
return comment;