This
blog will show how to use an ADF form to send email notification from Human
Task, when some action is taken on a task by the user or the task is assigned
to a user.
As a
prerequisite email configuration has to be done on the server using Enterprise
Manager and ADF form needs to be attached to your Human Task.
Once email configuration is done, we have to set up the notification
in Human Tasks and modify ADF form so that we can send it as Email.
Below are the steps for sending ADF
Form as email notification in From Human Task:
1.
Open a .task file (e.g
AccountDistributionHumanTask.task) for which email notification needs to be
set.
2. Click
on notification and go to Advanced Tab as shown below:
3. You
can select from two options as shown below:
We
selected send individual mails in our case.
4. Now
go to General Tab and click on add icon to add Task Status and Recipient as to
when and to whom you want to send the email notification:
5. If
you want to add a custom message i.e notification header, on the General Tab
click on pencil icon under Notification Header column as shown in the screenshot
below:
6. Write
your message in Edit Notification Message window as shown below and click OK.
Above
settings will pick up the corresponding email id of the user either from mail
attribute of embedded LDAP or from the task payload(depends on the requirement
and implementation). In our case we are sending a link to Worklist Application,
details of which is being picked up from payload for different environment.
7. Now
open the .jspx file in your ADF project and add a af:switcher inside af:form
and move the default facet(e.g f:facet-Worklist) inside the af:switcher. In the
same af:switcher add another f:facet(e.g f:facet-Email) for creating email
content to be sent in the Email, below screen shot shows the structure of
components:
For
creating email content you can use datacontrol and drag and drop attributes as
af:outputText to Email Facet(e.g select invoiceNumber and drag and drop on to
Email Facet) as shown below:
8. Add the following condition to FacetName
property of the af:switcher to let it decide which facet to display:
#{pageFlowScope.bpmClientType
eq 'notificationClient' ? 'Email' : 'Worklist'} as shown in below screenshot:
Now
when you run your application, above condition will decide whether bpmClientType
is notificationClient or not. If it is, then it will execute the Email facet and
the response will be based on whatever you put under the Email facet. When the
ADF form is accessed though a worklist, it will execute the “Worklist” facet
and display the complete form for user entry.
On
the other hand if you are not using ADF form, then the content of email will go
into Notification Header as shown earlier or you will have to use email
component of BPEL, where a lot of work has to be done in formatting because
both will use html tags to create the content.
So,
using the same ADF form, that you associate to a human task, you can generate
the email notification.
Much thanks to Siddhartha Agarwal for today's post!