The CreatorCon Call for Content is officially open! Get started here.

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!

8 REPLIES 8

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.

 

Hi @Brad Bowman  ,
Thanks for reply !
Yes, I mentioned the same way.

M Iftikhar
Tera Sage

Hi Deepika,

From what you've described, the issue is occurring because the event is being triggered on the sc_req_item table, but the notification is configured on the sysapproval_approver table. Since the event is not fired on the approver record, the notification never gets triggered during the RITM state change.

To resolve this, you can simply move the notification to the sc_req_item table (same as where the event is triggered). Update the notification as follows:

 

Table: sc_req_item
Send When: Event is fired
Event name: precheck.completed

Condition: current.state == 15

 

This way, the notification will properly trigger when the event precheck.completed is fired on the RITM.

 

Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.

Hi @M Iftikhar ,
Thanks for reply!

I made the changes as suggested but no luck.

DeepikaGangra1_1-1759211996389.png

BR:

DeepikaGangra1_2-1759212017952.pngDeepikaGangra1_3-1759212029609.png


When i making all on sc_req_item , no approver gets attached on RITM .

Thanks

Deepika