Change Custom Functions   

    Change custom functions can be used in change custom triggers. You could execute change custom functions as custom actions and global functions. While custom actions can be directly invoked in change custom triggers, global actions can be called in change custom actions.

    To create change custom functions, go to Admin > Problem/Change Management > Change Custom Function.

     

    Custom Actions   

    Custom actions are actionable custom functions that allow users to manipulate data in ServiceDesk Plus and other external applications. Custom functions are built on Deluge, Zoho's propriety scripting language.

    Custom actions can be used in Change Custom Triggers to perform actions on changes, other modules, and external applications.

    Use the following pointers to create, enable, disable, and delete custom actions.

    • Use the New button to create a custom action.

    • The Actions button allows you to bulk delete, disable, and enable custom actions. To modify individual custom actions, use the icons displayed next to the custom action. Note that only active custom actions will be available to use in the aforementioned configurations.

    • Use keywords to search custom actions in the field provided. Use the filters on top to display the custom actions used in specific features.

     

    Adding a New Custom Action   

    Click New on the custom action list view page.

    On the displayed page, provide a name and description for your custom action.

    Use the simple drag-and-drop interface called the Deluge Script Editor to build your custom action.

    As demonstrated in the following screenshot, 'changeObj' and 'context' will be passed as arguments for the custom function:

     

     

    You must write the custom function with changeObj as the argument.

     

    After executing the custom function, the Map data type will be returned in the following format:

     

    {
    "message":"Executed successfully",
    "status":"success/failure"
    }

     

    You can update the change fields, add notes, and update change roles 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.

     

    The new field values must be returned from the custom function in a specific format as demonstrated below:

     

    Let's consider a sample function to update change subject to 'Firewall Upgrade' and Priority to 'High'.

    returnJson = Collection();
    changeID = changeObj.get("id");
    instanceJson = context.get("instance");
    helpdeskID = instanceJson.get("id");
    inputData = {"change": {"title":"Firewall Upgrade","priority":{"name":"High"}}};
    resp = invokeurl
    [
    url: "http://servername:portnumber/api/v3/changes/" + changeID
    type: PUT
    parameters: {"input_data": inputData,"TECHNICIAN_KEY":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","PORTALID":helpdeskID}
    ];

    response_status = resp.get("response_status");
    if("success".equals(response_status.get("status"))) {
    returnJson.insert("result":"success");
    }
    else {
    returnJson.insert("result":"failure");
    }
    return returnJson;

     

    Note:

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

    To check out Deluge use cases, visit this page.

     

    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 change from the list of changes displayed and click Next.

    • The data that will be passed to the custom function will be displayed under the parameter 'changeObj'.

    • Click Execute.

     

    Note:

    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 changeObj and context, you can simply run the following script and study the response.

     

    info
    changeObj;
    info context;
    return true;

     

    For more details on Deluge, visit Deluge help guide.

     

     

    Zoho Corp. All rights reserved.