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.
Use Case: When a new Employee is joining in the organization based on resource question we need to create multiple child requests
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
Is New Device Required
Order a Laptop or Desktop
Is Dual Monitor Required
Is Deskphone/Extension Required
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|
|Is Dual Monitor Required|
|Is Deskphone/Extension Required|
Please refer the screenshot how I added the required template names based on these question values
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
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.
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.