How to automatically create multiple child requests from a parent request based on the resource question values (Copying parent UDF fields, Resource Information and parent attachments)

How to automatically create multiple child requests from a parent request based on the resource question values (Copying parent UDF fields, Resource Information and parent attachments)

Deluge Equivalent:

This is a sample Python script to automatically trigger the creation of multiple child requests from a parent request based on parent resource question values. The request ID of the child requests will be added as a Note in the parent request.

This is achieved using an API call to create a request in ServiceDesk Plus. Details of the child requests are stored in a JSON file and provided as the primary parameter to the script. The parent request details are stored as a JSON object in a file and its path is provided as the second parameter.  A separate API  is used to add the request ids of the child requests as notes to the Parent request. This is achieved using Request Custom Triggers and the link here will provide more information on that.

Note: For builds above 11300 use Files_latest.zip

Use Case: When a new Employee is joining in the organization based on resource question we need to create multiple child requests
For Example
1. Providing Laptop/Desktop based on the parent resource question
2. Providing Additional monitor
3. Providing Deskphone/Extension etc...
For example, here I am considering the New Hire Template with some resources questions



New Hire Template API response as follows




Based on the Resource question values I will create a new child requests

Resource Question
Value
Template Name
Is New Device Required
Yes
Order a Laptop or Desktop
Is Dual Monitor Required
Yes
Additional Monitor
Is Deskphone/Extension Required
Yes
Deskphone/Extension Request

Here I am attaching the Order a Laptop or Desktop, Additional Monitor,  Deskphone/Extension Request  Templates and their API response format

Order a Laptop or Desktop Template




Additional Monitor Template




DeskPhone/Exetention Request Template



As from the above screenshots, child requests also have some resource questions and UDF field information that has to be passed from the parent request, These things we can configure in the ChidRequestsV3.json file as Follows



Now we need to check the resource question value and based on that value we need to set the template name in the script MultipleRequestsV3.py,

Resource Question
API $ Format to get the value
Is New Device Required
$resources,$res_301,$qstn_simple_304,$name
Is Dual Monitor Required
$resources,$res_302,$qstn_simple_301,$name
Is Deskphone/Extension Required
$resources,$res_301,$qstn_simple_601,$name

Please refer the screenshot how I added the required template names based on these question values


Important Note:
1. Make sure that the criteria configured for the parent request in the custom trigger do not match the child requests during creation. If it matches, then it will end up in a loop, where the criteria will match and requests will be created in the loop.
2.Execution Command: py MultipleRequestsV3.py ChildRequestsV3.json $COMPLETE_V3_JSON_FILE

Execution steps:
1. Download the attached zip
2. Move all files to sdp_home/integration/custom_scripts folder
Note: Don't move configuration.json if there is a file with the same name exists
3. Edit configuration.json update url and technicianKey
4. Add the template names and child request details in the JSON configuration file labeled ChildRequestsV3.json.
(This change is based on your requirement)
5. Configure the script and its parameter under the Admin -> Custom Triggers. The script file to run parameter will be set as shown below.
Create a text file in [SDP_Home]/integration/custom_scripts/executor_files directory
File content : py MultipleRequestsV3.py ChildRequestsV3.json $COMPLETE_V3_JSON_FILE 

I've attached a screenshot showing a sample implementation below.




A short guide on setting up python is available here.

                  New to ADSelfService Plus?