Set Backup Approvers using Request

Set Backup Approvers using Request

This is a sample script that triggers BackUp Approver API, using request information. 

Use Case: 
Different users are provided for each role in many organisations. 
When a user is on leave for a particular number of days, their duty is delegated to another individual.  Additionally, users must obtain their manager's consent prior to taking a planned vacation or leave.  They can submit a request with the from and to dates, as well as the alternate person who will handle the approval procedure on their behalf. 
Once their supervisors have given their approval, the backup approver must be designated.

Execution steps:

1.Create a new Backup Approver Request Template with below additional fields:
  1. If the Requester is considered as the Approver for who the backup approver needs to be set, then Use 1 Single Line additional Field to store the Backup Approver name.
  2. If both approver and backup approvers need to be a configurable field then, Use 2 Single Line additional Fields, 1 >> Holds the Approver name and 2 >> Holds the backup approver name.
  3. 2 Additonal Date Fields - to hold from and to date
For Reference:

2.  Configure the FAFR script > On form load - for the user additional fields.  (Configure it twice if you choose to use 2 single line additional field)

3.  Modify the Additional field names as per your instance in the FAFR script.

4.  Goto Admin > Request Custom Function > Global Function > New > Paste the global function contents and save it with a name.
Update the URL and integration/technician key in the script. 
  1. For builds over 11300, you can get the integration key under Admin > Integrations > Integration Key > New
  2. Please use an integration key with admin privilege, as there wont be any role related permission issues. 

  3. For builds prior to 11300, refer https://help.servicedeskplus.com/api/rest-api.html$key and update the technician key.
5.  Go to Admin > Request Custom Functions > Custom Actions > Paste the content from the attachment (BackupApprover.txt) and save it with a name.
6.  Modify the global function name in the script. Refer to the attached screenshot. 
7.  Configure the created custom function in a trigger to get executed every time a BackUp Approver request is created.