Callback Function

You can manipulate data within ServiceDesk Plus Cloud whenever an event occurs in an external application using callback functions. For example, you can write a callback function to notify ServiceDesk Plus Cloud whenever a ticket is added in your bug tracking software, such as Backlog and update the necessary information in ServiceDesk Plus Cloud. A callback function is the same as a webhook, only triggered from an external application to perform a task within ServiceDesk Plus Cloud. 

Callback functions are internally executed through custom scripts, which allow you to perform all types of actions including API calls to external applications. 

 

Components of a Callback Function

Each callback function consists of an API name, a URL auto-generated for the given API name, and a custom function. The API name must be unique across the callback functions. The URL will be used by the external application users to invoke the callback function. 

You can also add parameters to a callback function. Parameters are the input to a custom function from external users when invoking the callback function.

 

Creating a Callback Function

  1. Go to Setup >> Developer Space >> Custom Function and select Callback Functions from the drop-down.
  2. Click New Custom Function.
  3. Provide a unique name to the callback function and enter a description.
  4. Provide a unique API name. A URL that is auto-generated using the API name will be displayed in the corresponding field.
  5. Select Publish to allow users to invoke the URL from external applications. 
  6. Optionally, you can type in the parameters and select the corresponding data type for each parameter.
  7. To test the script, click Save & Execute Script. Otherwise, click Save.
  8. At any time you want to suspend the access of the custom function by external users, you can unpublish the callback function.

 

Callback Functions List View

  1. You can import sample functions that come with the application into the Callback functions library. Click Import Sample Functions, select the function(s), and click Import Function.
  2. Perform bulk operations such as DeletePublish, and Unpublish on callback functions using the Actions menu.
  3. Use the Toggle button beside a callback function to publish or unpublish the callback function.
  4. Use the Settings icon beside a callback function to edit or delete the function or to edit its API details.
  5. View the details of a callback function by clicking it.

 

Invoking a Callback Function

External application users must provide the following values for fields while invoking any callback function:

URL: URL generated for the callback function

HTTP Request Method: POST 

For a callback function with parameters, the user must also provide the parameter values under the key arguments in the HTTP body. 

Parameter Value Format: arguments = {"<Parameter Name 1>":"<Parameter Value 1>", "<Parameter Name 2>":"<Parameter Value 2>", ...}

For example, arguments = {"name":"tom","id":123}