Scheduled Function

Scheduled Function

AssetExplorer allows administrators to execute custom schedules using a built-in script execution tool called scheduled functions. The scheduled function scripts can be built from scratch using deluge, Zoho's propriety scripting language.

Scheduled functions can be used to build your own automation operations such as sending notifications or updating asset status by analyzing the queries fetched from reports.

Role Required: SDAdmin

To create scheduled functions, go to Admin > Developer Space > Custom Functions > Scheduled Function.

You can create scheduled functions as Custom Actions or Global Functions.

Custom Actions

Custom actions are actionable custom functions that allow users to manipulate data in AssetExplorer and other external applications. You can write a script to fetch data from query reports and execute an action based on the fetched data.

Create Custom Actions  

Use the New button to create a custom action.

Provide a name and description for your custom action.

Use the simple drag-and-drop action to select objects from the deluge script editor onto the canvas.

You must write the scheduled function with reportObj as the argument.

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

  1. {
  2. "message":"Executed successfully",
  3. "status":"success/failure"
  4. }

You can perform the specified action by returning the map from the scheduled function. The format used in scheduled functions is same as the python script and class. For more details, visit this page.

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

Let's consider a sample script to update request status to Closed.

  1. input_data = {
  2. "request": {
  3. "status": {
  4. "name": "Closed"
  5. }
  6. }
  7. }
  8.  
  9. for each data in dataObj{
  10. workorderid = data.get("workorderid");
  11. requeserid = data.get("Requeser_Id");
  12. app_url = "http://servername:portnumber/api/v3/requests/" + workorderid;
  13. params = {"input_data": input_data};
  14. response = invokeurl
  15. [
  16. url: url
  17. type: PUT
  18. parameters: params
  19. headers: headers
  20. ];
  21. }
 

Within scheduled 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 scheduled function,

  1. Click Save and Test to test run the custom action.

  1. Choose a sample report from the list of reports displayed.

  1. The data that will be passed to the scheduled function will be displayed under the parameter reportObj.

  1. Click Execute.

The script will be executed, and the output will be printed along with info statements that are used for debugging.


If you make any API calls by using invokeurl while testing the scheduled function, the API will be invoked. Ensure that you don't invoke an API that might result in unintended consequences. 

Debugging Tip

When you test a scheduled function, you can debug the code and print the output by using a statement called info. For example, to understand the structure of reportObj and context, you can simply run the following script and study the response.

  1. info reportObj;
  2. info context;
  3. return true;



 For more details on Deluge, visit Deluge help guide. 

After a custom action is created, you can use it to create custom schedules. The custom schedule where the custom action is active is displayed in the custom action list view.

Custom Actions List View

After creating custom actions, you can manage them from the list view as follows:

  • Click the icon to edit or delete a custom action. To delete custom actions in bulk, select the custom actions and go to Actions > Delete.

  • Click the icon to disable a custom action. Disabled custom actions are indicated using the icon that you can click to enable a custom action. To enable/disable in bulk, select the custom actions and go to Actions > Mark as Active/Mark as Inactive.

  • Use keywords to search custom actions from the search bar.

  • Click the filter drop-down to display all custom actions or just the ones used in custom schedules.


 Only active custom actions will be available to use in the configurations mentioned above 

    • Related Articles

    • Global Functions

      Custom functions allow users to manipulate data in AssetExplorer and other external applications. Custom functions are built on Deluge, Zoho's propriety scripting language. Global functions are custom functions that can be called from custom actions ...
    • Custom Schedules

      Custom schedules enable you to access any data from AssetExplorer and schedule periodic customized actions such as sending notifications or updating asset details. You can also synchronize AssetExplorer data with other third-party applications to ...
    • Scheduling Reports

      Using Schedule Report Settings, you can automate generating multiple reports, in various formats, at scheduled times. These reports can be generated in PDF, XLS, XLSX, HTML, Inline HTML, CSV, DOC, DOCX, or XML formats and shared via email or saved to ...
    • Exclude CIs from Scan

      Exclude certain CIs from being scanned during automated or scheduled scan. Use case: CIs in restrictive environments or with unique configuration requirements can be excluded from scanning. On the CI list view, select the preferred assets. Go to ...
    • General Scan Settings

      Role Required: SDAdmin To access general scan settings, go to Admin > Discovery > Scan Settings > General. Configure Invalid Service Tags If the service tags are incorrectly configured by the OEM, different machines may have the same service tag and ...