In BPEL, human workflow is almost always expected to be represented by a single human task activity with multiple steps - that is why the Oracle SOA Suite 11g Human Task component has a lot of facility for notification related to the raise of events like the assign, error, expire, withdraw, alert, complete, and etc. on a particular task definition.
But in the current release of BPM (18.104.22.168), it is different. Each task participant or steps in the workflow are represented by a different task definition, and to notify the initiator of a process instance, upon approval or disapproval of a request or a completion of a certain activity, needs to be configured on a separate service call activity, and definitely, not covered by the facilities of Human Task component.
And there goes the topic of this blog post - How to send notification to the initiator of a BPM process instance upon completion of an activity?
First, of course you need to have a properly set-up email driver configuration. If you still don't, then you could take advantage of gmail as the smtp server as describe on my previous post - Using GMail as Mail Server for Oracle SOA Suite 11g Notifications.
Secondly, you need to obtain the the necessary wsdl and xsd files of the NotificationService available from BPEL. This is describe in one of Niall Commiskey's charming blog post - BPM 11g and Notifications.
Third, we need to get the email address of the initiator of a bpm process instance so we can set it as the addressee on a NotificationService service call. This is the thing that will be described on this post ;)Before we can get the email address on the initiator, we need to know the username of the initiator first. My first bet was to use the BPM Extension Function - "bpmn:getProcessInstanceAttribute('creator')", but this doesn't seem to work as of 22.214.171.124 in which I am getting some internal exceptions that says - "the variable is not defined in the current scope". As an alternative, the initiator username can be acquired through the following xpath expression available from BPEL Xpath Extension Functions:
ora:getCreator()To get email address of a specified user we can use the following xpath expression from the Identity Service Functions:
ids:getUserProperty()Excerpt from the expression builder:
Get a user property. The signature of this function is ids:getUserProperty(userName, attributeName, realmName) The arguments to the function: 1) userName - String or element containing the user whose attribute should be retrieved 1) attributeName - String or element containing the name of the user attribute. The attribute name should be one of the following values: givenName middleName sn displayName mail telephoneNumber homephone mobile facsimileTelephoneNumber pager preferredLanguage title manager 3)realmName - The realm name. This is optional and if not specified default realm is assumed.
And finally, below is the compound expression to access the email address of the initiator of the process instance: