You're reading...
Business Event

Notifications from Workflow Business Events

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.

About these ads

About Abhijit Ray

I love sleeping, watching Hollywood blockbusters, my Wii, road trips and watching my 4 year old son grow up. In between I try to squeeze in some time to go to work.

Discussion

2 thoughts on “Notifications from Workflow Business Events

  1. while raising event in wf_event.raise we use to pass the 5 parameters can you please let me know where we can get the value?

    Posted by anirban roy | April 10, 2014, 10:03 am

Trackbacks/Pingbacks

  1. Pingback: Raising business events via concurrent requests/programs | Oracle Maniacs' Notes - March 6, 2014

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Traffic

Site Stats

  • 504,180 views since Feb 2012

Archives

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 175 other followers

Flags

Free counters!
Follow

Get every new post delivered to your Inbox.

Join 175 other followers

%d bloggers like this: