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 data between ServiceDesk Plus MSP Cloud and any third-party applications.
Using Custom Functions in Schedules
- Go to Setup > Developer Space > Custom Functions > Scheduled Functions. (You can alternately write the custom function while creating a schedule.)
- Click New Custom Function.
- Provide a name and description for your custom function.
- Write the custom function on the Deluge Script Editor and then save the function.
The custom function used in schedules has the input argument 'context' that contains 'instance'. 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:
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.
Debugging Tip
When you test a custom 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();
Sample
Let's say your organization has a general practice of scheduling change requests in the distant future. Users involved in each of those change requests might lose track of time and fail to notice the beginning of the change request processing. Using the following script, you can send reminders to select users on specific dates prior to the change request processing.
- /*Provide the email address to be notified*/
- toEmail = "<email address>";
- /*Enter how many days before the change request's scheduled start must the notification be triggered*/
- reminder = "<number of days>";
- /*Provide the name of the portal in which you want to execute the custom function*/
- portalName = "<portal name>";
- /*Gets the current system time*/
- currentTime = zoho.currenttime.tolong();
- /*Determines the one-day window based on which the change requests must be fetched*/
- reminderValueEnd = currentTime + reminder.toNumber() * 86400000;
- reminderValueStart = reminderValueEnd - 86400000;
- /*Constructs criteria to fetch change requests*/
- changeParameter = {"input_data":{"list_info":{"row_count":"1","start_index":1,"search_criteria":{{"field":"scheduled_start_time.value","condition":"gte","value":reminderValueStart},{"field":"scheduled_start_time.value","condition":"lt","value":reminderValueEnd,"logical_operator":"and"}},"sort_field":"scheduled_start_time","sort_order":"asc"}}};
- /*Makes an API call to get the change requests that fulfill the specified criteria*/
- response = zoho.sdp.invokeurl
- [
- url :"/app/" + portalName + "/api/v3/changes"
- type :GET
- parameters:changeParameter
- ];
- /*Gets the change requests from the response of the API called*/
- changes = response.get("changes");
- /*Checks if there is at least 1 change request in the response of the API called.*/
- if(!changes.isEmpty())
- {
- /*Contructs the change request ID to send in the email*/
- scheduledChangeId = changes.get(0).get("display_id").get("display_value") + "<br><br>";
- /*Constructs 'Description' for the email*/
- mailDescription = "The following change request will start in " + reminder + " days.<br><br>" + scheduledChangeId + "<br><br>This is an automated message. Please don't reply to this email.";
- /*Constructs 'Subject' for the email*/
- mailSubject = "Reminder for change request in ServiceDeskPlus Cloud";
- /*Makes an API call to send the email*/
- mailResponse = zoho.sdp.invokeurl
- [
- url :"/app/" + portalName + "/api/v3/changes/" + changes.get(0).get("id") + "/notifications"
- type :POST
- parameters:{"input_data":{"notification":{"to":{toEmail},"subject":mailSubject,"description":mailDescription,"type":"SEND_MAIL_ONLY"}}}
- ];
- }
- return Map();
For a quick summary of how to use custom functions across different features in ServiceDesk Plus MSP Cloud, visit this link.