Trigger a notification if flow execution fails

anuj27
Tera Expert

Hi All,

I have requirement that I need to fire a email notification to a particular users if flow execution for any of the 7 flows gets any error and flow fails. 

 

Consider these 7 flow as A,B,C,D,E,F,G.

 

I created a notification named XYZ (send when : Triggered).

 

Now please guide me how to move forward in steps to achieve this functionality successfully.

Thanks

 

1 ACCEPTED SOLUTION

Mohan raj
Mega Sage

Hi @anuj27,

 

I understand that need to send email notification if flow was cancelled or error.

  • Here we can trigger an email by script for that need to create event register first by Navigating  system policy >> Event >> Registry   create new (to trigger email)
  • In Notification select send when : Event fired
    and Event name : choose the event name from drop down(select event created in first step)
  • And try this below script 

 

var flow = new GlideRecord('sys_flow_context');//this table has all flow excution status
flow.addEncodedQuery('sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');//created today
flow.addQuery('state','ERROR')
flow.addQuery('state','CANCELLED');
flow.query();
var count = flow.getRowCount();
if(count >= 7){ //check record more than or equal to 7 records
    gs.eventQueue('<event_name>',flow,'<sysid of the user>')
}

   

 

If this response is useful then hit thumbs and give like to response and mark as accept solution

Regards

Mohan

View solution in original post

3 REPLIES 3

Mohan raj
Mega Sage

Hi @anuj27,

 

I understand that need to send email notification if flow was cancelled or error.

  • Here we can trigger an email by script for that need to create event register first by Navigating  system policy >> Event >> Registry   create new (to trigger email)
  • In Notification select send when : Event fired
    and Event name : choose the event name from drop down(select event created in first step)
  • And try this below script 

 

var flow = new GlideRecord('sys_flow_context');//this table has all flow excution status
flow.addEncodedQuery('sys_created_onONToday@javascript&colon;gs.beginningOfToday()@javascript&colon;gs.endOfToday()');//created today
flow.addQuery('state','ERROR')
flow.addQuery('state','CANCELLED');
flow.query();
var count = flow.getRowCount();
if(count >= 7){ //check record more than or equal to 7 records
    gs.eventQueue('<event_name>',flow,'<sysid of the user>')
}

   

 

If this response is useful then hit thumbs and give like to response and mark as accept solution

Regards

Mohan

Hi Mohan,

Thanks for guiding me.

 

Plz Just have a look on it.

1. I have created a new event in event register.

s1.PNG

Fired by is : Business Rule , right ?

other fields are ok ? 

 

2. Created  a notification , send when : Event is fired.

s2.PNG

Do i need to add this script in advanced condition script section ? 

Or since the event is set to fired by Business rule, I need to create a BR. If yes which BR is needed here.

 

 

 

 

 

Hi @anuj27,

 

Use Business rule to trigger the email notification