Sunday, February 19, 2017

Stop Old Outbound Workflow Notification Emails after Clone

I followed below document to cancel/purge R12.1.3 notifications:
How To Purge E-Mail Notifications From The Workflow Queue So The E-Mail Is Not Sent (Doc ID 372933.1)

It gives a query getting notifications that would be sent, and are waiting to be e-mailed when the Mailer get started:

SQL> select notification_id, begin_date, recipient_role, message_type, message_name, status, mail_status
 from wf_notifications
where Status In ('OPEN', 'CANCELED')
   and Mail_Status In ('MAIL', 'INVALID')
   and begin_date < sysdate-30              -- List only emails older than 30 days ago
order by notification_id;

SQL> select count(*) from wf_notifications
         where status in ('OPEN', 'CANCELED')
         And Mail_Status In ('MAIL', 'INVALID')
         order by notification_id;
  COUNT(*)
----------
    271022
SQL> select count(*) from wf_notifications
    where status in ('OPEN', 'CANCELED')
    and Mail_Status In ('MAIL', 'INVALID')
    and begin_date < sysdate-30;    -- List only emails older than 30 days ago
  COUNT(*)
----------
    270991
SQL> create table apps.wf_notifications_BK_120816 as
    select * from wf_notifications
    where status in ('OPEN', 'CANCELED')
    and Mail_Status In ('MAIL', 'INVALID')
    and begin_date < sysdate-30;
Table created.

SQL> update WF_NOTIFICATIONS set mail_status = 'SENT'
    where status in ('OPEN', 'CANCELED')
    and Mail_Status In ('MAIL', 'INVALID')
    and begin_date < sysdate-30;
270998 rows updated.
SQL> commit;
Commit complete.

SQL> @$FND_TOP/patch/115/sql/wfntfqup.sql apps apps_PWD applsys
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.76
Commit complete.
Elapsed: 00:00:00.00
**** TEMPORARY TABLES / AQs created ****
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.27
**** Messages backed up ****
Commit complete.
Elapsed: 00:00:00.00
**** wfaqback.sql completed,  executing SQLs from wfntfqup
PL/SQL procedure successfully completed.
Elapsed: 00:00:04.60
***  invoking wfaqrenq.sql ******
*** Re-enqueing messages
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.02
Commit complete.
Elapsed: 00:00:00.01
***** Re-enqueue OF Alerts completed *****

I tried to use an email address to hold the old notifications after SMTP works fine on the CM server. Seems to me that the "Set Override Address" will not work until the Mailer was started, because prior to that, it would not send the Verification Code out to the email address.

References: Doc ID 562551.1 includes two old documents:

- How to Cancel Email Notifications for Particular Workflow Type (Doc ID 736508.1 for 11i)
- How To Stop Old Outbound Workflow Notification Email Messages During Clone Activity (Doc ID 828812.1 for 11.5.9 to 12.0.0)

No comments: