Business rule to run when Additional comment changes

VineJosh
Tera Contributor

Description : I have to create an event that fires when additional comments changes and the state does not changes to PUA or PU.

Solution implemented: 

Business rule: 

When to run :
state is one of = New,Pending Change, Pending Parts, Pending vendor, Work in Progress, Resolved.
OR
Additional comment changes.

Advavanced:

(function executeRule(current, previous /*null when async*/ ) {
if (current.state.changesTo(23) || current.state.changesTo(18)) {

current.setAbortAction(true);

} else {

if (current.comments.changes() && current.sys_updated_by == current.assigned_to.user_name) {
gs.eventQueue('Trigger_event_incident_comments', current, gs.getUserDisplayName(), current.comments);
} else if (current.comments.changes() && current.sys_updated_by == current.caller_id.user_name) {
gs.eventQueue('Trigger_event_incident_comments', current, gs.getUserDisplayName(), current.comments);
} else if (current.comments.changes() && current.sys_updated_by == current.watch_list.user_name) {
gs.eventQueue('Trigger_event_incident_comments', current, gs.getUserDisplayName(), current.comments);
}
}
})(current, previous);



Results:
The notification is triggering only when both additional comments have changed and state is changed.

1 REPLY 1

Uncle Rob
Kilo Patron

Why would you have a state bias on a comment.  Comments are intended to go to the customer no matter what.