Output JSON format for Custom Scripts

The document provides information on the JSON format that needs to be returned from a custom script. 

General format

The class/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. The JSON has the following format:

{
"result":"success",
"message":"Message"
}

 

Operations Supported

Some operations can also be performed using the return JSON. The JSON structure to invoke the operations is as follows:
 {
  "message": "Message",
  "result": "success",
  "operation": [
    {
      "OPERATIONNAME": "operation_1",
      "INPUT_DATA": [
        {
          
        }
      ]
    },
    {
      "OPERATIONNAME": "operation_2",
      "INPUT_DATA": [
        {
          
        }
      ]
    }
  ]
}
 
Some of the operations supported for custom triggers are as follows:
 
        * EDIT_REQUEST
        * ADD_NOTE
        * ADD_APPROVAL_STAGE
        * ADD_APPROVAL
        * SET_APPROVAL_STAGE
        * SET_APPROVAL
 
 
EDIT_REQUEST JSON
 
Updates the mentioned fields in the request.
 
{
  "message": "Request Updated Successfully",
  "result": "success",
  "operation": [
    {
      "OPERATIONNAME": "EDIT_REQUEST",
      "INPUT_DATA": [ 
{
  "request": {
    "technician": {
      "name": "Heather Graham"
    },
    "priority": {
      "name": "High"
    },
    "request_template": {
      "name": "New Hire"
    },
    "udf_fields": {
      "udf_sline_301": "high priority",
      "udf_pick_603": "windows",
      "udf_multiselect_302": [
        "Net Beans",
        "Eclipse"
      ]
    }
  }
}
      ]
    }
  ]
}
 
All the input parameters listed here can be updated this way.
 
ADD_NOTE JSON
 
Adds a note to the request.

{
  "result": "success",
  "message": "Note Added Successfully",
  "operation": [
    {
      "OPERATIONNAME": "ADD_NOTE",
      "INPUT_DATA": [
        {
          "note": {
            "description": "Sample text",
            "show_to_requester": true
          }
        }
      ]
    }
  ]
}


ADD_APPROVAL_STAGE JSON
 
Adds new approvers for mentioned stages, in addition to the existing set of approvers.
 
Triggering the approval for the first stage is controlled by the send_immediately parameter. When set to true, the approval request will be sent immediately. When set to false, the user has to send the approval request manually.
 
{
  "message": "Sample Python script for adding new approvers for all stages, in addition to the existing approvers",
  "result": "success",
  "operation": [
    {
      "OPERATIONNAME": "ADD_APPROVAL_STAGE",
      "send_immediately": "true",
      "INPUT_DATA": [
        {
          "StageOne": [
            "Sampleuser.1@xyz.com",
            "Sampleuser.2@xyz.com"
          ]
        },
        {
          "StageTwo": [
            "Sampleuser.3@xyz.com",
            "Sampleuser.4@xyz.com"
          ]
        },
        {
          "StageThree": [
            "Sampleuser.5@xyz.com",
            "Sampleuser.6@xyz.com"
          ]
        },
        {
          "StageFour": [
            "Sampleuser.7@xyz.com",
            "Sampleuser.8@xyz.com"
          ]
        },
        {
          "StageFive": [
            "Sampleuser.9@xyz.com",
            "Sampleuser.10@xyz.com"
          ]
        }
      ]
    }
  ]
}
 
ADD_APPROVAL JSON
 
Adds new approver for the current stage, in addition to the existing set of approvers.
 
Triggering the approval for this stage is controlled by the send_immediately parameter. When set to true, the approval request will be sent immediately. When set to false, the user has to send the approval request manually.
 
{
  "message": "Sample Python script for adding new approvers in current stage, in addition to the existing approvers",
  "result": "success",
  "operation": [
    {
      "OPERATIONNAME": "ADD_APPROVAL",
      "send_immediately": "true",
      "INPUT_DATA": [
        "Sampleuser.1@xyz.com",
        "Sampleuser.3@xyz.com",
        "Sampleuser.5@xyz.com"
      ]
    }
  ]
}
 
 
SET_APPROVAL_STAGE JSON
 
Removes the existing set of approvers in the mentioned stages before adding new approvers. The approvers who have already approved will not be removed from the approvers list.
 
Triggering the approval for the first stage is controlled by the send_immediately parameter. When set to true, the approval request will be sent immediately. When set to false, the user has to send the approval request manually.
 
{
  "message": "Sample Python script for adding new approvers for all stages, in addition to the existing approvers",
  "result": "success",
  "operation": [
    {
      "OPERATIONNAME": "SET_APPROVAL_STAGE",
      "send_immediately": "true",
      "INPUT_DATA": [
        {
          "StageOne": [
            "Sampleuser.1@xyz.com",
            "Sampleuser.2@xyz.com"
          ]
        },
        {
          "StageTwo": [
            "Sampleuser.3@xyz.com",
            "Sampleuser.4@xyz.com"
          ]
        },
        {
          "StageThree": [
            "Sampleuser.5@xyz.com",
            "Sampleuser.6@xyz.com"
          ]
        },
        {
          "StageFour": [
            "Sampleuser.7@xyz.com",
            "Sampleuser.8@xyz.com"
          ]
        },
        {
          "StageFive": [
            "Sampleuser.9@xyz.com",
            "Sampleuser.10@xyz.com"
          ]
        }
      ]
    }
  ]
}
 
SET_APPROVAL JSON
 
Removes the existing set of approvers in the current stage and adds new approvers. The approvers who have already approved will not be removed from the approvers list.
 
Triggering the approval for this stage is controlled by the send_immediately parameter. When set to true, the approval request will be sent immediately. When set to false, the user has to send the approval request manually.
 
{
  "message": "Sample Python script for adding new approvers in current stage, in addition to the existing approvers",
  "result": "success",
  "operation": [
    {
      "OPERATIONNAME": "SET_APPROVAL",
      "send_immediately": "true",
      "INPUT_DATA": [
        "Sampleuser.1@xyz.com",
        "Sampleuser.3@xyz.com",
        "Sampleuser.5@xyz.com"
      ]
    }
  ]
}