The following scenario simulates a simple leave approval business process, in which an employee fills a form and submits the leave request to the manager and the manager approves or rejects it. The employee receives an email if the manager approves the request. Otherwise, if the manager rejects it, the employee will be able to resend the leave request by adjusting it.
Tip | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Before you begin,
and download it from here.
|
Let's get started! This tutorial includes the following sections:
...
- Download the pre-packaged project and extract it to a preferred location. This contains the artifacts of the Working with Exclusive Gateways tutorial.
- Open the WSO2 Integration Studio.
- Click File, and click Import.
- Expand the WSO2 category, select Existing WSO2 Projects into workspace and click Next.
- Click Browse, select the file you extracted and upload it.
- In the Package Explorer, double click on the name of the BPMN diagram to view the BPMN artifacts you imported.
Creating new artifacts
...
- In the Main Config section of the Properties tab (of the Mail Task), fill the respective fields (i.e., To, From, Subject). You can give the Subject as
Leave approved!
. In the Non-HTML field of the Main Config section, enter
Hi ${employeeName}, your leave request is approved
. The variable will be used to create the mail body.Expand title More information on the properties of the Mail Task The Mail Task allows you to send an email within a BPMN Process. It is configured with the following properties.
Field Name Mandatory Description To Yes The email address of the intended recipient of the email. Multiple recipients can be specified as comma-separated email addresses. From No The email address of the sender. If this field is not specified, the default email address specified in the activiti.xml
file will be used.Subject No Subject of the email. CC No The email addresses of the carbon copy receivers of the email. Multiple recipients are separated by commas. Bcc No The email addresses of the blind carbon copy receivers of the e-mail. Multiple recipients are separated by commas. Charset No Charset of the email can be changed. Html No The content of email is in HTML format. Text No Content is in non-HTML format. Copy the following JAR files into the
<EI_HOME>/lib
directory and restart the Business Process profile server instance.https://repo1.maven.org/maven2/org.apache.commons:/apache/commons/commons-email/1.3.1/commons-email:jar:-1.3.1.jar
- https://repo1.maven.org/maven2/javax/mail/mail/1.4.mail:mail:jar:7/mail-1.4.7.jar
- https://repo1.maven.org/maven2/javax/activation/activation/1.activation:activation:jar:1.1 1.1/activation-1.1.1.jar
In the
<EI_HOME>/wso2/business-process/conf/activiti.xml
file, add the following properties under the<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
property as shown below, to enable the Gmail configurations.Replace the
mailServerHost
andmailServerPort
property values as follows:Code Block language xml <property name="mailServerHost" value="smtp.gmail.com"/> <property name="mailServerPort" value="587"/>
Add the following properties:
Code Block language xml <property name="mailServerDefaultFrom" value="<ENTER_A_VALID_SMTP_EMAIL_ADDRESS>"/> <property name="mailServerUseTLS" value="true"/> <property name="mailServerUsername" value="<ENTER_A_VALID_SMTP_EMAIL_ADDRESS>"/> <property name="mailServerPassword" value="<ENTER_THE_EMAIL_PASSWORD>"/>
Expand title More information on the above properties Property Description <property name="mailServerDefaultFrom" value=”email of the sender”>
This specifies the default address of the sender. If a sender is not specified in the sender field as a mail task property, the email address specified here will be used instead. <property name="mailServerUsername" value="mailtask@gmail.com"/>
<property name="mailServerPassword" value="mailtask123"/>
Specifies the credentials of the sender for authentication purposes. Here, you should include the email address and it's corresponding password which you specified in the “From” field of the mail task. Port 456 (SSL required):<property name="mailServerUseSSL" value="true"/>
Port 587 (TLS required):<property name="mailServerUseTLS" value="true"/>
Specify only one of these two properties in order to specify whether the mail server should use SSL or TLS. Info If you are using Gmail to try out this scenario, you may need to enable IMAP access for Gmail. For more information, see Enable IMAP settings in Gmail . Also, if you receive an authentication error, you may have to adjust your account access settings in Gmail as well. For more information, see Allowing less secure apps to access your account .
Deploying the artifacts
- For instructions on creating the deployable artifacts, see Creating the deployable archive.
- For instructions on deploying them, see Deploying BPMN artifacts.
...
If you have not started the business processor profile previously, start it.
Panel borderColor #542989 bgColor #ffffff borderWidth 1 Localtabgroup Localtab title On MacOS/Linux/CentOS Open a terminal and execute the following command:
Code Block wso2ei-6.46.0-business-process
Localtab title On Windows Go to Start Menu -> Programs -> WSO2 -> Enterprise Integrator 6.46.0 Business Process. This will open a terminal and start the business process profile.
- Log in to the Management Console of the Business Process profile.
- Click Configure → Users and Roles → Add → Add New User.
Enter the below details to create a user called
manager
and click Next.Tip Enter both the User Name and the Password as
manager
.In the next screen, assign the user to the
admin
role and click Finish.You view the new user you created as shown below.
Testing the output
...
- Log in to the BPMN-explorer at https://localhost:9445/bpmn-explorer using
admin
for both the username and password. - Click PROCESSES in the top menu, and click the Start option of the Leave Approval Process.
Initiate the process by filling the form and click Start.
You view a pop-up message upon successful process initiation.
Initiate the process again by filling the form again and click Start .
Tip You create two tasks to test the output of both leave approval and leave rejection.
- Log out and log in again using
manager/manager
credentials. - Click TASKS and then click MY TASKS. You view two tasks created.
Click on the first task, select A pprove from the drop down list and click Complete Task.
An email will be sent to the employee confirming that one of your leave requests was approved by the manager.
- Click TASKS and then click MY TASKS again, click on the second task, which is left now, select Reject from the drop down list and click Complete Task .
- Log out and log in again with
admin/admin
credentials, and click TASKS → MY TASKS.
You view the Adjust vacation request T ask.
- Click on the Adjust vacation request T ask, change the details and click Complete Task to resend the leave application.
- Log out and log in again with
manager
/manager
credentials, and click TASKS → MY TASKS . - Click on task, select A pprove from the drop down list and click Complete Task .
Another email will be sent to the employee confirming that your second leave request was also approved by the manager.