Create an Approval Task

We have already seen how to create an Input Task in Workflows. Now let us understand how to create an Approval Task in Studio Workflow. An Approval Task is a request/action that an approver reviews and responds to, either as an approval or rejection of the action.

Let us take an example to create a leave management screen, where the user would add a leave request which would be then sent to the Manager or a specific user for approval. Now here we have two activities to consider when creating the workflow; define the assignee or approver, define the action to be taken on approval and the action on rejection

Adding the Approval task

Create a sheet with the columns for Leave type, date of leave, leave reason and approval status. Create a form with a dropdown control for the Leave type, date picker for date of leave and text area control for leave reason. Add a Submit button to submit a leave application for approval. Once done you need to add a Workflow and link it to the submit button.

Add a workflow to the form / screen and name it as ApprovalWorkflow. Select the Approval task and click Continue. When an employee submits a leave application, a workflow should trigger the approval task which will send a notification to the employee’s manager.

This configuration needs to be done in the Approval tasks as follows -

Assign the task

You need to select the user to whom you would want the task to be assigned for approval. Select the assignee for this task. It can be assigned to the Initiator, or last user, or to a group of users based on a filter or even directly to an individual user.

For the sake of this example, we would assign it to the initiator.

You can also assign it to the initiator’s manager.

It can also be assigned to a group of users related to the initiator.

Once you have configured the assignee of this task, click Done to save the Approval task. On saving, the approval task will be displayed in the workflow editor as shown below.

Any approval task has two paths, Approve & Reject. Either of these paths will execute when the assignee of the approval tasks opts for either approval or rejection of the request.

You can further add tasks under each path as per the requirement (which will execute only when the approval task is approved or rejected) by clicking the respective ‘+’ icons.

In this example let us add an insert task that will record the leave request as well as status as to whether approved or rejected. The Approvalstatus column would be updated as per the action of approval or rejection.

Now you can add new tasks below the Approval Tasks, by clicking on the ‘+’ icon, below the Approve/Reject endpoints connect (as shown in the image below). This task will always be evaluated irrespective of whether the approval task for Approved or Rejected.

To insert records to a sheet, add the Update Sheet task and click Continue. Enter the task name and provide the sheet name to insert a record into. Now bind the controls to the columns from the sheet. The leave type, leave date, and leave reason will have the respective controls linked. Now for the Approval Status column, you want to assign the value as per the task approval or rejected. Now select the user action done from the Leave_Approval task earlier. So in this example, it will be Leave_Approval.USERACTION which would have values as ‘approved’ or ‘rejected’. These values would be thus stored according to the action taken. The records would be inserted in the sheet.

Note:
Now that you have created the app and added the workflow for approval as well as insert data, you need to publish it first before you can receive the notifications to your web app or mobile app.

Now when the app is run after publishing you can see the notification in the Status App bar > Updates as shown below.

For the sake of this example we had assigned the task to the initiator so you can note the notifications received in the updates tab as well as on the mobile device.

Here you can click Approve or Reject and the insert record task would be triggered in the background. The Approval_status column would also be updated as per the action.

approval granted

You can thus use the approval task for initiating action from the specified users. There can be different actions that you may add after the approval or rejection like inserting or updating data, triggering a notification email, and so on.