Send emails to non Oracle Apps users through workflow

By Jag - April 04, 2014

Emails can be sent to persons or organizations external to Oracle apps. For instance suppliers or customers might need certain notifications from Oracle after a certain approval process. The approval process is handled by workflow. Workflows send out emails to Oracle apps users as they are configured within Oracle. Workflow can send emails to external email addresses as well. We only need to configure it.
The following code can be used to create the workflow role for the external email address. This is done because the workflow has to send a notification which will then be interpreted by the email server and sent out as an email. The workflow role will contain the email address.
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
   v_chk_role   NUMBER;
   v_cc_email   VARCHAR2 (100) := 'abhijit673@gmail.com';
BEGIN
   -- If the user does not exist, create it. The role
  -- will be created automatically and the user and role
   -- will also be mapped automatically
 
   -- Check whether the role exists or not
   SELECT COUNT (1)
     INTO v_chk_role
     FROM wf_roles
    WHERE NAME = v_cc_email;
 
  -- The role/mail address has to be in UPPER case for the mail server
   -- to send an external email
   v_cc_email := UPPER (v_cc_email);
 
   IF lv_chk_role = 0
   THEN
      wf_directory.createadhocuser (NAME                          => v_cc_email,
                                    display_name                  => v_cc_email,
                                    LANGUAGE                      => NULL,
                                    territory                     => NULL,
                                    description                   => 'EY PO Supplier user',
  notification_preference => 'MAILHTML',
                                    email_address                 => v_cc_email,
                                    fax                           => NULL,
                                    status                        => 'ACTIVE',
                                    expiration_date               => NULL,
                                    parent_orig_system            => NULL,
                                    parent_orig_system_id         => NULL
                                   );
   END IF;
EXCEPTION
   WHEN OTHERS
   THEN
      NULL;
END;
Note: The email address and the role name have to be entered in UPPER case or else the email server will be unable to send the email. This is true only for external email addresses.
Now we shall query the workflow tables,
1
select * from wf_roles where name = upper('abhijit673@gmail.com')
1
select * from wf_user_roles where role_name = upper('abhijit673@gmail.com')
After we trigger off the workflow we can check the activity history in workflow monitor,
Click on the notification,
Note the value of ID in the notification header. This is the notification id which we shall query for in the database and check for the email status.
1
select * from wf_notifications where notification_id = 5455150
The mail_status shows SENT. This means the recipient has received the email
  • Share:

You Might Also Like

0 comments