Introduction
There are various ways of sending workflow notifications using Workflow Activities like Notification Activity with ‘Expand Roles’ flag checked, Notification Activity without ‘Expand Roles’ flag checked, APIs like WF_NOTIFICATION.Send, WF_NOTIFICATION.SendGroup, and using Business Event System Subscription Action Type ‘Send Notification’.
Using Workflow Activities
A notification can be sent by running a workflow process having
the notification activity. The recipient of the notification can be set
by using the Performer attribute in the notification activity, and the message template can be set using the Message attribute. If the
performer value is a role, then the ‘Expand Roles’ flag will be used to
decide whether to send the same copy to all the users of the role or a
different copy.
Notification Activity without “Expand Roles”
The ‘Expand Roles’ flag will be unchecked by default,
sends the same copy of notification to all its users and that notification is visible in the notification queue of all the
users in that role. If one user in that role responds to or closes that
notification, the notification is removed from the notification queue
of all other users in that role.
Notification Activity with “Expand Roles”
The ‘Expand Roles’ flag when checked, sends a different copy of the notification to all its
users. The notification remains in a user’s notification queue until the user responds to or closes the notification. By both checking Expand Roles and specifying a post-notification
function, you can create a voting activity. A voting activity is a notification activity that first sends a
notification message to a group of users in a role and then executes a PL/SQL
post-notification function to tally the users’ responses and determines the transition to the next activity.
Refer to WF dev guide for more details about voting activity.
Using APIs
A notification with the specified message can be sent to the role by calling the WF_NOTIFICATION.send() and WF_NOTIFICATION.sendGroup() APIs without actually launching the workflow process. The message template that needs to be sent has to be defined within a
workflow item type .
WF_NOTIFICATION.Send
This function sends the specified message to a user/role and returns a
notification ID if successful. The specification of the function is shown below.
function SEND
(role in varchar2,
msg_type in varchar2,
msg_name in varchar2,
due_date in date default null,
callback in varchar2 default null,
context in varchar2 default null,
send_comment in varchar2 default null
priority in number default null)
return number;
Example:
declare
nid number;
msg_type varchar2(100) := 'WFTESTS';
msg_name varchar2(100) := 'PLSQL_MSG';
role varchar2(320) := 'TESTUSER';
begin
nid := wf_notification.send(role, msg_type, msg_name);
commit;
end;
/
WF_NOTIFICATION.SendGroup
This function sends a separate copy of notification to all the users assigned to the specified role and returns the notification group ID if
successful. All the notifications have the same group id, which is
the first notification id sent.
function SendGroup
(role in varchar2,
msg_type in varchar2,
msg_name in varchar2,
due_date in date default null,
callback in varchar2 default null,
context in varchar2 default null,
send_comment in varchar2 default null
priority in number default null)
return number;
Example:
declare
nid number;
msg_type varchar2(100) := 'WFTESTS';
msg_name varchar2(100) := 'PLSQL_MSG';
role varchar2(320) := 'TESTUSER';
begin
nid := wf_notification.SendGroup(role, msg_type, msg_name);
commit;
end;
/
Using Business Event System Subscription Action Type
The notification can also be sent by raising the business event for which the subscription action type is specified as ‘Send Notification – Send a notification using a standard or custom message template’. As part of the subscription definition, the workflow item type and message name for the message you want to send and role that should receive the notification must be specified. In this approach, you do not need to define or run a workflow process to send a
notification from a subscription.
However, you do need to define the message you want to send within a
workflow item type. The list of values for the Message Name field
includes only the messages within the item type you specify.
Following are the subscription mandatory parameters
- Message Type – An item type that contains the message definition
- Message Name- An message template for the notification you want to send
- Recipient – A role that should receive the notification
- Priority – Normal, High, or Low as the priority for the message.
Following are the subscription optional parameters
- Callback – Custom callback function you want the Notification System to use for communication of SEND and RESPOND source message attributes.
- Context – The context information for a workflow process instance that needs to passed to the callback function. The context information consists of
the item type, item key, and activity ID in the following format:
<itemtype>:<itemkey>:<activityid> - Comment – A comment to send with the message