Add an Extra Approver for Site New York
In this exercise you will learn how to add an extra approver to an approval task.
Parking spaces in New York are expensive. This means that a parking reservation for the New York Widget Headquarters, requires the manager of the requester to give an approval when the duration is for more than 2 days.
Create a new Task Template Automation Rule on the ‘Reserve a Parking Space – Approval’ task with the name ‘Add an Extra Approver for the Site New York’. You know how to write the statements for the following:
- Execute this action when the automation task gets the status ‘Assigned’,
- Retrieve the site record based on the Site UI extension value,
- Retrieve the site name.
Next check if the site name contains the word ‘Headquarters’.
is_new_york |
site_name contains ‘Headquarters’ |
Now you need to check if the duration of the reservation is longer than 2 days. To do so:
- Get the ‘From’ and Until dates;
- Add 2 days to the ‘From’ date;
- Check if this date falls earlier than the ‘Until’ date.
This is:
from |
request.custom_fields.from |
until |
request.custom_fields.until |
max_until |
from + 2.days |
is_longer_2_days |
until > max_until |
This gives us all the conditions for this automation rule
Condition | is_assigned and is_new_york and is_longer_2_days |
Before you start with the actions, you first need to retrieve the manager of the requester (where the requester is the ‘requested_for’ person from the Request). Get the requester and the requester’s manager with following expressions:
requester |
request.requested_for |
manager |
requester.manager |
As explained in a previous exercise, multiple approval records can be linked to a task. All the approvals of a task are the collection, ‘Approvals’, and with the following action you will add an extra approval record to the “Approvals’ collection:
Update | current record |
Add | manager to approvals |
You need both of the 2 approvers to approve, so you will set the approval task attribute, required_approvals, to 2:
Update | current record |
Set | required_approvals = 2 |
Test this automation rule: reserve a parking space in New York and check if the manager of the requested_for is added as a second approver to the approval task when the reservation duration is longer than 2 days.