With Execute Script action in business rules, you can validate requests and update field values to automate request workflows. You can use scripts for validation of requests that involve complex conditions or requests that use third-party application inputs.
You can execute business rule scripts on requests incoming through browser, API, mobile, and mail.
A user logs a service request for an asset.
In this case, you can write a script to automatically check the asset availability, then allocate it to the request, and update the asset status in the Asset module.
You can simply define what's not allowed for a requester or a technician, whether it's data modification or the operation itself in any given stage of the request processing.
A user logs a service request for a new laptop. During this request processing, you can use Business Rules script execution in the following cases:
To prevent request duplication when the same requester raises a request for the same category, sub-category, and item.
On the displayed text box, enter the file name containing the script and click Save.
Consider the case to raise a Jira ticket from ServiceDesk Plus. To configure a custom script for this action,
Create a text file with the command given below:
Save the file as create-jira-ticket.txt and place it under [SDP_HOME]/integration/custom_scripts/executor_files directory.
When configuring the custom action, enter the file name in the executor field.
Click Save after providing all the other details.

During execution, the application will fetch the command from the given text file.
$COMPLETE_V3_JSON_FILE denotes the path of a file that has complete request details, previous and updated field values in the JSON format. The file is temporary and it will be automatically deleted after the script is executed.
The temporary JSON file is created in SDP_Homeintegrationcustom_scriptsrequest directory, file name being <requestid_timestamp>.json.
$COMPLETE_V3_JSON_FILE structure
{
"request": {
<all request properties in V3 format>
},
"diff": {
"old": {
"request": {
"priority": {
"id": "4",
"name": "High"
},
"urgency": {
"id": "3",
"name": "Normal"
},
"impact_details": "High impact for servers"
}
},
"new": {
"request": {
"priority": {
"id": "1",
"name": "Low"
},
"urgency": {
"id": "4",
"name": "Low"
},
"impact_details": "Low impact for servers"
}
}
},
"LOGIN_NAME": "administrator",
"LOGGEDIN_USER_TYPE": "Technician",
"LOGGEDIN_USER_NAME": "administrator",
"OPERATION_TYPE": "add"
}
Input is in JSON. Here the request key contains the user given fields and fields filled by system in V3 API format.
The script for requests file should return a JSON which has the success/failure status and a message which will be displayed in the history tab of the request.
General format:
{
"result": "success",
"message": "Message"
}
The server script must write the output JSON (if any) to the same temp file that is provided to the script. You must not invoke external API calls to update the same request because this will not allow the updated values to be carried forward to the cascading business rules.
You can perform Update and Negate operations using the JSON return.
Example for Update operation
{
"result": "success",
"message": "Sample Python script",
"operation": [
{
"OPERATION_NAME": "UPDATE",
"INPUT_DATA": [
{
"request": {
"urgency": {
"name": "High"
},
"group": {
"name": "Network"
},
"priority": {
"name": "High"
}
}
}
]
}
]
}
Example for Negate operation
{
"result": "success",
"operation": [
{
"OPERATION_NAME": "NEGATE",
"REASON": "Negate Reason"
}
]
}
Click here to view the sample script for the below use case: