In the previous example I demonstrated how to trigger a PL/SQL function from a business event. In this article I shall illustrate how to send a notification from a business event.
For demonstration I shall create a subscription to the event I had created earlier. You can check it out here. In this example I shall add another subscription to the same event to send a notification. Thus there will be 2 subscriptions on the same event. Once the event is raised it will trigger off both subscriptions.
Step 1: Create the workflow message
Create the workflow

Create the message

Ensure that the workflow message has the same attributes that will be used while raising the event. If the message does not use the same attributes the message will not be sent and the Event subscription will error out.
Step 2: Create the subscription
Query for the event created

Click on the Subscription icon

Click on Create Subscription button and enter the details as shown below.

Note that the Action Type is set to Send Notification. Click on Next button.
- Enter the Message Type with the internal name of the workflow we have created in Step 1.
- Enter the Message Name with the internal name of the message in the workflow.
- Enter the Recipient as SA1. This means that only the user SA1 will receive the notification.
- The Owner Name and Owner Tag should be valid application names.

Click on Apply button on the right hand side and you will get a confirmation message.

Click on Cancel button and you will get to see all the subscriptions for the event.

Now the configuration is complete.
Test the subscription
We shall raise the event using PL/SQL we can execute the following code. As an alternate you can raise the event directly from the OAF page. This is shown in the previous article.
DECLARE
x_event_parameter_list wf_parameter_list_t;
x_user_id INTEGER := 140;
x_user_name VARCHAR2(100) := 'PennePasta';
x_param wf_parameter_t;
x_event_name VARCHAR2(100) := 'xx.oracle.apps.test';
x_event_key VARCHAR2(100) := 'PP001';
x_parameter_index NUMBER := 0;
BEGIN
x_event_parameter_list := wf_parameter_list_t();
--Lets add the first value to the Event Parameter i.e. user_id
x_param := wf_parameter_t(NULL
,NULL);
x_event_parameter_list.EXTEND;
-- Set the value for the first Event Parameter i.e. User ID
x_param.setname('XX_TEST_USER_ID');
x_param.setvalue(x_user_id);
x_parameter_index := x_parameter_index + 1;
x_event_parameter_list(x_parameter_index) := x_param;
-- Set the value for the second Event Parameter i.e. User Name
x_param := wf_parameter_t(NULL
,NULL);
x_event_parameter_list.EXTEND;
x_param.setname('XX_TEST_USER_NAME');
x_param.setvalue(x_user_name);
x_parameter_index := x_parameter_index + 1;
x_event_parameter_list(x_parameter_index) := x_param;
-- Raise the event
wf_event.RAISE(p_event_name => x_event_name
,p_event_key => x_event_key
,p_parameters => x_event_parameter_list
/*,p_event_data => p_data*/
);
END;
/
Query the table XX_EVENT_RESULT. You will find the data passed in the PL/SQL to raise the event (refer to the previous article)

Now we shall login to Oracle as SA1 user to check whether the notification is sent or not. After logging in as SA1 user we can see the notification on top of the list of open notifications in the Worklist section.

This is done by clicking on Full List button. We find the notification as shown below.

Click on the notification.

We can view the notification sent by the Event subscription.
Thus we see that both event subscription has been executed simultaneously by raising the same event.
Addendum
If we had sent some workflow message as a notification which did not have the same attributes as the ones we had raised then the subscription would have resulted in an error and an Error workflow, System: Error, would have been executed to send the error to the System Administrator. The process within the workflow that sends this notification is Default Event Error Process.
If you check the workflow in Status Monitor,

Check the Activity History of the first workflow,

Check the Notification


The error message within the notification tells us that the attribute does not exist in the message.
Cheers.
Related articles
- Workflow Business Event demo (oraclemaniac.com)
- Send workflow notifications from PL/SQL without executing the workflow (oraclemaniac.com)
- How to develop Master – Detail workflow process (oraclemaniac.com)
- How to start a workflow using PL/SQL (oraclemaniac.com)
- How to send/test workflow notifications in Production instances (oraclemaniac.com)
- Send emails to non Oracle Apps users through workflow (oraclemaniac.com)
- Notifications from Workflow Business Events (oraclemaniac.com)
- How to reassign an approval notification to an approver from a PO buyer responsibility (oraclemaniac.com)
- PL/SQL code to set profile option values (oraclemaniac.com)

Discussion
No comments yet.