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.
- Go to Setup > Developer Space > Callback Functions.
- In the module drop-down, select Callback Functions.
- Click New Custom Function.
- 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:
|
*mandatory fields
- 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.
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.
- info context;
- 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.
- /*Note that you must pass the request ID in the following format to the HTTP request's body of the callback function. */
- arguments = {
- "requestId" : "<your request Id>"
- }
- /*Specify the portal of the request to which the note must be added*/
- portal_name = "<your portal>";
- /*Specify the note*/
- note_description = "<your note here>";
- /*Triggers an API call to add a note to the request*/
- response = zoho.sdp.invokeurl
- [
- url :"/app/" + portal_name + "/api/v3/requests/" + requestId + "/notes"
- type :POST
- parameters:{"input_data":{"request_note":{"description":note_description}}}
- ];
- 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 ...