Deluge Scripting in Callback Functions 

Callback functions allow you to manipulate data within ServiceDesk Plus 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 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 Cloud. 

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

To learn more about Callback functions, click here.

 

Using Custom Functions in Callback Functions

To write a custom function that can be used as a callback function, follow the steps given below:

 

Define the parameters required by the callback function. The custom function must return a 'Map' object. The returned Map object is currently not processed. 

You can also return an empty map by using the following syntax: 
 

 return map();  

 

Sample

The following script adds 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();

 
 

Test Execution of Scripts 

After writing the custom 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 custom function, the API will be invoked. Make sure you don't invoke an API that might result in unintended consequences. 

 

For a quick summary of how to use custom functions across different features in ServiceDesk Plus Cloud, visit this link