How to capture last work note and comment in Business rule on Task?

Kevin McGartlan
Tera Contributor

Hello, 

I would like to capture the last work note or comment on a task. My business would like to use these fields for reporting purposes. I currently have a business rule setup to capture those fields by using the code below. This is an after Business Rule on update/insert: 

function executeRule(current, previous /*null when async*/) {

current.u_last_comment = current.comment.getJournalEntry(1);
current.u_last_work_note = current.work_notes.getJournalEntry(1);
//current.u_entered_by_comments = current.comments.

})(current, previous);

I'm not sure what's wrong here. The u_last_comment and u_last_work_note were both setup initially as Strings, but I changed them to Journal just in case there was a variable mismatch. Still no luck. Any ideas on what to do here?

Also, I wanted to see if I can grab the "Entered By" and "When" of the last work note/comment as well. Is there any functions I can use to get that data as well? 

Thank you!

1 ACCEPTED SOLUTION

I'm glad I was able to assist you with getting that to work successfully.

When pulling the last journal entry...doesn't it say in that the name of the person and the date/time? It does for me.

But you could at the same time, use current.updated_by and place that somewhere as well which pulls who did it and then use current.sys_updated_on to get the date/time.

Please mark my other reply as Helpful and this one as Correct if this helps you solve it.

Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

11 REPLIES 11

same way you can do that.

is there any column which store the "Date Entered, and Entered By" value? and where exactly you want to store?

 

eg:

 

i have a one field which store the Date Entered ( created ) and "Entered By" (created by)

the value i want to store in one field description

current.description = current.sys_created_on + current.sys_created_by ;

I'm glad I was able to assist you with getting that to work successfully.

When pulling the last journal entry...doesn't it say in that the name of the person and the date/time? It does for me.

But you could at the same time, use current.updated_by and place that somewhere as well which pulls who did it and then use current.sys_updated_on to get the date/time.

Please mark my other reply as Helpful and this one as Correct if this helps you solve it.

Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!