How to implement dynamic request approval using FAFR and custom triggers.

How to implement dynamic request approval using FAFR and custom triggers.

This is a sample script written in Python to handle Conditional Approvals for Incident \ Service Requests, through Custom Triggers using Field and Form Rules.  One of the advantages of using this script is that there is no modification of the script is required to get the script working.  The approvers can be configured through FAFR and this is easier to modify without server access.

Use Case:  
Let's assume that in a large organization, when users request a service from a long list of offerings, it makes no sense if all the services go through the same set of approval processes. As most of the services would have a different set of approvers and approval levels, it is mandatory to customize the request approval processes.  This post helps IT, administrators, to dynamically set approvers at different approval stages directly in the request without the need to configure them in the template. With the help of Field and Form rules, the list of approvers are set in the request additional fields which will be used to send approvals.

Requirements:
2. functions.py :  This package consists of all the functions that are used to handle the standard requirements of the customer.  Most repeated requirements are written as separate functions.  Depending on our use case, we can include these functions in our script. 
3. configuration.json : This file maintains the configuration details of the installed server.  

Execution Steps:
1.  Create new additional fields for the request to hold the approver information and update the api name in the script. Attached the Screenshot.
2.  Each stage must be configured as a separate additional field.
3.  Go to Admin > Service Templates > Select a particular template > Field and Form Rules > Rule execution - On Create / Edit > Event - "On Field Change" - "Requester" > Conditions - "Department=Network" > Actions - Set Field - First additional field - Set the list of approvers.  Eg:  shawnadams@sdplinmail.com,$REPORTING_TO$
4.  Similarly set values for the required number of stages and move status to "Waiting for approval".
5.  Extract the ZIP file under ..\ManageEngine\Servicedesk\integration\custom_scripts - folder.
6.  Edit the configuration.json and update the values.
7.  Configure a custom trigger to get invoked when the "Status" is "Waiting for approval".  Go to Admin > Custom Trigger > give a trigger name > execute script > py addApprovals.py $COMPLETE_V3_JSON_FILE and set the criteria as "Status=Waiting for approval"

Field and Form Rule:






Custom Trigger:


                  New to ADManager Plus?

                    New to ADSelfService Plus?

                      • Related Articles

                      • Script to set fields from CSV using FAFR.

                        Works in 10604 Requirement: Load Data from CSV depending on the value selected in an additional field. Usecase: Assume there are 3 additional fields for a request template, namely, "Reference number", "Payment type and "Vendor". "Reference number" is ...
                      • Notification script using Custom function in custom trigger

                        This is applicable from 10600 builds. From 10600 , Business rules dont have Email notification feature. The same use case be achieved through Custom triggers feature as mentioned below. Script to enable notification of request creation using custom ...
                      • Close the request upon adding a note.

                        Kindly follow the steps mentioned below: 1) Go to Admin >> Developer Space >> Custom Function >> Global Functions >> Copy & Paste the attached GF_Content.txt and save it with a name. Update the URL and technician key as per your instance. Refer to ...
                      • Ability to mandate the reason for field updates in requests using custom triggers

                        Use case: At times, technicians may not provide the reason for request fields update as technician reassign, groups, priority and so on. This script will alert the technicians to update the reason for these request field updates. Prerequisites: ...
                      • Custom Script to Trigger an Alert if there is no email address associated with Requester (using FAFR)

                        Working on Builds: 14500 too Scenario: Request should not be created if there is no email address associated with the requester. Instead it should prompt and alert stating there is no email address associated with the requester. The above requirement ...