Request Custom Functions

Request Custom Functions

Request custom functions can be used in business rules, request custom triggers, request life cycle, and request timer actions. Using custom functions, you can perform automated actions on requests, other modules, and external applications.
Go to the following pathway in the application to create request custom functions,
  • Old UI: Admin > Incident Management > Request Custom Function.
  • New UI: Admin > Developer Space > Custom Function > Request

Add New Custom Function 

  • Click Add New.
  • Provide a function name and description.
  • Provide an API name to call the custom function.
  • Use the simple drag-and-drop interface called the Deluge Script Editor to build your custom function.
  • Click Save or Save and Test.
 'requestObj' and 'context' will be passed as arguments for the custom function.


Ensure the custom function is written with requestObj as the argument. After execution, Map data type will be returned in the following format:
 {
"message":"Executed successfully",
"status":"success/failure"
} 
You can update the request fields, add notes, and add conditional approvals for the request by returning the map from the custom function. The format used in these custom functions are same as the python script and class. For more details, visit this page.
You can update the following default request fields in requestObj:
subject, resolution, mode, group, item, level, impact, service_category, update_reason, priority, udf_fields, impact_details, subcategory, status, request_type, description, urgency, technician, category. You could also update additional fields in requestObj.
You could also update additional fields in requestObj.
The new field values must be returned from the custom function in a specific format as demonstrated below:
Let's consider a sample script to update request subject to 'Firewall Upgrade' and Priority to 'High'.
 returnjson = {
"operation": [{
"INPUT_DATA": [{
"request": {
"subject": "Firewall Upgrade",
"priority": {"name": "High"}
}
}],
"OPERATIONNAME": "UPDATE",
"FORMAT": "V3"
}],
"result": "success",
"message": "Request updated!!"
};

return returnjson; 
Let's say you want to assign high priority to requests from Network/Internet category. You can automate this action by using the following script in a business rule action/custom trigger action/request life cycle/timer during and after rules:
 returnjson = Map(); 
 if(requestObj.containsKey("category"))
{
    if(requestObj.get("category").get("name") == "Internet" || requestObj.get("category").get("name") == "Network")
    {
        returnjson = {
"operation": [{
"INPUT_DATA": [{
"request": {
"priority": {"name": "High"}
}
}],
"OPERATIONNAME": "UPDATE",
"FORMAT": "V3"
}],
"result": "success",
"message": "Request updated!!"
};
    }
}
return returnjson; 

Within request custom functions, you can call global functions that can store information essential to connect with external applications, common functionalities, and configurations.

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 request from the list of requests displayed and click Next.
  • The data that will be passed to the custom function will be displayed under the parameter requestObj.
  • Click Execute.
 If you make any API calls by 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 requestObj and context, you can simply run the following script and study the response.
 info
requestObj;
info context;
return true; 

List View 

Use the following pointers to enable, disable, and delete custom actions.
  • Use the filter drop-down on the toolbar to display custom functions based on the automations they are used in.
  • Click % beside a custom function name to edit or delete it.
  • Click % or % to enable/disable custom functions.
  • You can also bulk delete/enable/disable custom functions using the Actions menu.
  • Use keywords to search custom functions in the field provided.
For more details on Deluge, visit Deluge help guide.

    • Related Articles

    • Global Functions

      Global functions are custom functions that can be called from custom functions configured for request They can store information that is essential to connect with external applications, common functionalities, and configurations, all of which can be ...
    • Custom Actions

      Custom actions refer to user defined actions that can be performed on different entities across modules. For a custom action to be performed on an entity, it should be used with automation rules, subject to the availability of support. Availability ...
    • Custom Triggers for Notes

      Use custom triggers to automatically set off predefined actions on a note that matches the criteria. You can configure email/SMS notifications, custom functions, or even custom scripts as custom actions. Custom triggers are categorized and executed ...
    • Custom Triggers for Approvals

      Use custom triggers to automatically set off predefined actions when an approval matches a defined criteria. You can configure email/SMS notifications, custom functions, or even custom scripts as custom actions. Custom triggers are categorized and ...
    • Custom Triggers for Notifications

      Use custom triggers to automatically set off predefined actions on a notification that matches the criteria. You can configure email/SMS notifications, custom functions, or even custom scripts as custom actions. Custom triggers are categorized and ...