Problem Custom Functions
Problem custom functions can be used to perform custom actions such as updating problem fields and problem title, assigning priority, adding notes, associating incidents with problems, and the like. You can also use custom functions to manipulate data in ServiceDesk Plus MSP and other external applications. Custom functions are built on Deluge, Zoho's propriety scripting language. Problem custom function can be used in problem custom trigger.
To Create a Problem Custom Function
-
Go to Admin > Developer Space > Custom Function.
-
Navigate to Problem.
-
Click New.
-
Provide a name and description for the custom function.
-
Use the Deluge Script Editor's simple drag-and-drop interface to build your custom action.
-
Click Save.
As shown in the below screenshot 'problemObj' and 'context' will be passed as arguments for the custom function.
You must write the custom function with problemObj as the argument. After executing the custom function, the Map data type will be returned in the following format:
{ |
You can update problem fields, problem title, add notes, and associate incidents by returning the map from the custom function. The format used in the custom functions is the same as the python script and class. For more details, visit this page.
You can update default problem fields and additional fields in problemObj.
The new field values must be returned from the custom function in a specific format as follows:
Sample script to update problem title to Firewall Upgrade and priority to High:
returnjson ={
"operation": [
{
"INPUT_DATA": [
{
"problem": {
"priority": {
"name":"High"
},
"title": "FireWall Upgrade"
}
}
],
"OPERATIONNAME": "UPDATE",
"FORMAT": "V3"
}
],
"message": "Sample Update Python script",
"result": "success"
};
return returnjson;
Sample script to assign problem priority and update title based on problem category
if(problemObj.containsKey("category"))
{
if(problemObj.get("category").get("name") == "Internet" || problemObj.get("category").get("name") == "Network")
{
returnjson = {
"operation": [{
"INPUT_DATA": [{
"problem": {
"priority": {"name": "High"},
"title":"Network Issue"
}
}],
"OPERATIONNAME": "UPDATE",
"FORMAT": "V3"
}],
"result": "success",
"message": "Problem updated!!"
};
}
}
return returnjson;
Test Execution of Scripts
After writing the custom function, you can test it by following the steps given below:
-
Click Save and Test.
-
Choose a sample problem from the list of problems displayed and click Next.
-
The data that will be passed to the custom function will be displayed under the parameter problemObj.
-
Click Execute.
If you make any API calls using 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 problemObj and context, you can simply run the following script and study the response.
info |
For more details on Deluge, visit Deluge help guide.
List View Actions
-
Edit/Delete Custom Function - To edit/delete a custom function, click the Actions icon beside the custom function.
-
Enable Custom Function - Click to enable the custom function.
-
Disable Custom Function - Click to disable the custom function.
-
Bulk Actions - Use the Actions drop-down to bulk delete, enable, or disable the custom function. To perform this action, select the required custom functions by enabling the corresponding check boxes and click Actions.
-
Search for Custom Function - Enter keywords in the search field to search for custom functions.
-
Filter Custom Function - Use the filter drop-down on top to display the custom function used in specific features.