- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 02:01 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 02:41 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 02:41 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 03:11 AM
Hi Mohan,
Thanks for guiding me.
Plz Just have a look on it.
1. I have created a new event in event register.
Fired by is : Business Rule , right ?
other fields are ok ?
2. Created a notification , send when : Event is fired.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 03:22 AM