Blog

Last Comment or Work Note

It is useful to store the date/time of the last comment or work note for use in other business rules, client scripts, or SLA definitions.

Dictionary

You can choose to store both the last comment and last work note in separate fields. Or if you are just looking for the Last Comment, just add the single dictionary entry.

Dictionary Entry - Last Comment

Table: Task
Type: Date/Time
Readonly: true
Column label: Last comment
Column name: u_last_comment

Dictionary Entry - Last WORK NOTE

Table: Task
Type: Date/Time
Readonly: true
Column label: Last work note 
Column name: u_last_work_note

Business Rules

Same for business rules. If you just want to store the last comment and not the work note date, just use the last comment business rule.

Business Rule - Last Comment

Name: Last comment
Table: task
Insert: true
Update: true
Advanced: true
When: before
Condition: current.comments.changes()
Script:
(function executeRule(current, previous /*null when async*/) {
	current.u_last_comment = gs.nowDateTime();
})(current, previous);

BUsiness Rule - Last WORK NOTE

Name: Last Work Note
Table: task
Insert: true
Update: true
Advanced: true
When: before
Condition: current.work_notes.changes()
Script:
(function executeRule(current, previous /*null when async*/) {
	current.u_last_work_note = gs.nowDateTime();
})(current, previous);