Prototyping a Workflow-Driven Application in a Day – Part 2
In the first part of this tutorial, we created a new workflow package with three participants using Joget Workflow. Now, we're going to define the workflow activities involved in the leave application approval process.
Now, before we proceed any further, we're going to take a look at some workflow elements that we'll be using in this tutorial.
- Activity: A logical step within a process, which requires human for execution
- Tool: An activity which can be automated by computer / system using Joget Plugin. A tool must be placed within a system participant/swim lane.
- Route: Logical AND or Exclusive OR split, commonly used for decision routing.
- Transition: Linkage between activities and conditions.
Figure 2.1: Activity, Tool, Route and Transition in Workflow Designer Toolbar
Define Activity, Route, Tool and Transition for a Process
Using the Activity, Tool, Route and Transition components, draw the process diagram as shown in Figure 2.2.
Tip: You can stop using any of the selected tool by pressing Esc key, right-click, or the Selection arrow in toolbar.
Figure 2.2: Add Activities, Route, Tools and Transitions into Leave Application Approval Process
Now, we're going to edit the default properties of the workflow activity and tool, in the sequence as shown in Figure 2.2.
- Id: submit_leave_application
Name: Submit Leave Application
- Id: leave_approval
Name: Leave Approval
- Id: approval_condition
- Id: email_approved_app
Name: Email Notification of Approved Application
- Id: email_rejected_app
Name: Email Notification of Rejected Application
Indicate Start and End of a Process
At this stage, all activities and routes are illustrated, but we need to indicate the start and end process bubbles.
Figure 2.3:Insert Missing Start and End Bubbles
We can do this easily by clicking the "Insert missing start and end bubbles" button. By now, you should have a process diagram as illustrated in Figure 2.4
Figure 2.4: Leave Application Approval Process
Define Workflow Variable
In order to trace the decision made in the "Leave Approval" activity for conditional logical comparison in the route, we need to declare a workflow variable.
On the Navigator panel on the left, right click on "Leave Approval Process" and select "Properties". Click to open the "Workflow Variables" tab, and click the "Create new element" button, as shown in Figure 2.5.
Figure 2.5: Workflow Variables
Create a workflow variable "status" of type String.
Then, we also need to define in which activity the value of "status" workflow variable will be set. In this case, the "Leave Approval" activity will set the "status" workflow variable.
Double click on "Leave Approval" activity, and select the tab labeled "Activity form editor". By default, the "status" workflow variable is set as View. With reference to Figure 2.6, click the checkbox and the "status" workflow variable will be toggled to Edit. Which means, "Leave Approval" activity is now allowed to edit the "status" workflow variable.
Figure 2.6: Activity Form Editor
Define Logical Condition
Take note that there are two transitions (arrows) -- one branching to "Email Notification of Approved Application", while another branches to "Email Notification of Rejected Application". Now, we need to define the condition that will trigger each of these transitions.
Double click the transition branching out from decision route to "Email Notification of Approved Application". Select "Condition" from the Condition Type select box, and type the following expression into the Expression textarea:
status == 'approved'
Double click the transition branching out from the decision route to "Email Notification of Rejected Application". Select "Otherwise" from the Condition Type select box.
This means that we're telling the workflow engine that if the "status" workflow variable is equal to 'approved', then execute "Email Notification of Approved Application". Otherwise, run the tool named "Email Notification of Rejected Application".
Now, you should have a process diagram as illustrated in Figure 2.7
Figure 2.7: Leave Application Approval Process
From the top menu, select Process > Check validity. If everything is designed accordingly, you should get "No Error" in the Validation Report.
Deploy this process into Joget Workflow, by clicking File > Deploy.
Process Deployed as Version 1
Back to the Workflow Management Console, click Design Process > Update Existing Process, and you will be presented with a listing table of all the deployed processes.
The "Leave Approval Process" should be listed and versioned as 1.
If you update the process design of "Leave Application Process" from Workflow Designer, this process will be revised to a new version.
In the next part of this tutorial (Part 3), we're going to map the workflow participants to Joget Workflow users, as well as activities to data forms.