Script to close FYI workflow notifications from backend

Sometimes we end up in a situation to close notifications in bulk, in such situation we can use “wf_notification.close” API. Below is the script to close all OPEN notifications of an Item Type XX_NOTIF.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
DECLARE
  --
  -- +=====================================================
  -- | Purpose  : To close email notification
  -- | Author   : Shailender Thallam
  -- +=====================================================
  --
  CURSOR cur_list_notifications
  IS
  --
  --Modify the below query as per your requirement
  --
    SELECT item_key,
      notification_id,
      recipient_role
    FROM wf_notifications
    WHERE 1          = 1
    AND message_type LIKE 'XX_NOTIF'
    AND STATUS       = 'OPEN';
  --
  --
  l_item_key wf_notifications.item_key%TYPE;
  --
  --
BEGIN
  --
  FOR i IN cur_list_notifications
  LOOP
    BEGIN
      --
      wf_notification.close(i.notification_id,'SYSADMIN');
	  dbms_output.put_line ('Closing Notification ID: '||i.notification_id);
      --
    END;
  END LOOP;
  --
  COMMIT;
  --
END close_sample_creation_notif;