Callback Functions

Callback Functions

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

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

Configure Callback Functions

  1. Go to Setup > Developer Space > Callback Functions.
  2. In the module drop-down, select Callback Functions.
  3. Click New Custom Function.
  4. Fill out the necessary information as described in the below:
Field
Description
Custom Function Name*
Provide a unique name for the custom function.
Description
Describe the objective and usage of the custom function.
API Name
Provide a unique API name for the callback functions.
URL to execute this Custom Function
A URL is auto-generated for the given API name. The URL will be used by the external application users to invoke the callback function.
Publish
Enable to allow users to invoke the URL from external applications.
If disabled, the access to the callback function will be suspended to external users.
Parameters
Optionally, you can type in the parameters and select the corresponding data type for each parameter.
Parameters are the input to a custom function from external users when invoking the callback function.
Deluge Script Editor
Compile the custom function in the Deluge Script Editor using a simple drag-and-drop motion.
You can also return an empty map by using the following syntax:
  1. return map();
*mandatory fields
  1. After compiling the custom function, click Save or Save & Execute Script.

Points to remember:

Ensure custom function returns "Map" value.

Test Execution of Scripts   

After writing the callback function, you can test it by clicking Save & Execute Script. The script will be executed and a success/failure message will be displayed.
Info
If you make any API calls (by using zoho.sdp.invokeurl or invokeurl) while testing the callback function, the API will be invoked. Make sure you don't invoke an API that might result in unintended consequences.  

Debugging Tip   

When you test a callback function, you can debug the code and print the output by using a statement called info. For example, to understand the structure of 'context', you can simply run the following script and study the response.
  1. info context;
  2. return Map();
 

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}

Sample Script

Add a note to a specific request when the callback function is invoked.

  1. /*Note that you must pass the request ID in the following format to the HTTP request's body of the callback function. */
  2.     arguments = {
  3.         "requestId" : "<your request Id>"
  4.     }
  5. /*Specify the portal of the request to which the note must be added*/
  6. portal_name = "<your portal>";
  7. /*Specify the note*/
  8. note_description = "<your note here>";
  9. /*Triggers an API call to add a note to the request*/
  10. response = zoho.sdp.invokeurl
  11. [
  12.     url :"/app/" + portal_name + "/api/v3/requests/" + requestId + "/notes"
  13.     type :POST
  14.     parameters:{"input_data":{"request_note":{"description":note_description}}}
  15. ];
  16. return Map();
 
For a quick summary of how to use custom functions across different features in ServiceDesk Plus MSP Cloud, visit this link.
    • Related Articles

    • Custom Functions

      Overview Custom functions allow you to manipulate data within ServiceDesk Plus MSP Cloud and external applications. You can use custom functions to configure complex conditions or define multiple actions. For example, data under any module can be ...
    • Scheduled Functions

      Automate the execution of custom functions at regular intervals of time using schedules. For example, you can configure a schedule to escalate requests that have remained unapproved for a definite time to the stakeholders. You can also regularly sync ...
    • Asset FAQs

      Asset Management License Consumption and Asset States Will an asset be included in license consumption if it is moved to a disposed or expired state? No, Disposed or Expired assets do not consume license. How to create an asset state similar to ...
    • Overview

      Using Deluge scripting, you can build custom functions that allow you to manipulate data within ServiceDesk Plus MSP Cloud and other external applications. Custom functions help simplify complex, multi-step actions through program scripts that you ...
    • Overview

      Deluge, or Data Enriched Language for the Universal Grid Environment is Zoho's proprietary scripting language bundled with ServiceDesk Plus MSP Cloud. It is a high-level language that helps non-programmers code without any training. Unlike ...