Trigger Approval Notification on state changes

Deepika Gangra1
Tera Expert

Hi All,

I have a requirement to trigger approval notification only when state changes to Pre-Check Completed (custom state) on RITM. Currently It triggering only when approver is attached to RITM not on the states changes.
Please find the below event , BR , Notification condition overview and let me know where need to adjust the code.

event Name :precheck.completed
Table :sc_req_item

Br: Trigger Notifctaion on RITM PreCheck / After - Update
Table :Sc_req_item 
script :

(function executeRule(current, previous /*null when async*/) {
    if (current.state.changesTo(15)) {
   
        gs.eventQueue("precheck.completed", current, current.requested_for, gs.getUserID());
    }
})(current, previous);

Notification
Table: sysapproval_approver
Condition: 
sysapproval.getTableName() == 'sc_req_item' && sysapproval.state == 15

Looking forward for your response.

Thank you in Advance!

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

Since you have a Business Rule triggering an event, assuming that is working correctly, your Notification should be set to Send when 'Event is fired', not 'record inserted or updated' then choose your event in the Event name field

BradBowman_0-1759166373302.png

 

You likely then don't need the conditions, if your BR is only triggering the event when it should.