Configuring a Scheduler

A scheduler will be triggered at a definite time to execute a workflow. A list of attributes is passed when the scheduler is triggered. Take a look at the table given below:

AttributeDescription
userThe user map gives details about the creator of the scheduler.

Scheduler Execution & Response

A scheduler once executed can post the message in a chat or channel or in a bot with the help of three deluge tasks:

Post to a chat


zoho.cliq.postToChat("chat_id",message");

 

Post to a channel


zoho.cliq.postToChannel("channel_unique_name",message);

 

Post to a bot


zoho.cliq.postToBot("bot_unique_name",message) ;

Scenario

Let us try to create a scheduler which gets the list of tasks in a project and will be executed every Monday and Friday to track the task list and the status for the particular week. Create by giving the name, description followed by the recurring period and the time of execution. Take a look at this GIF illustration on creating the task status scheduler. 

Sample Scheduler Code Snippet



message = Map();
response = invokeurl
[
    url :"https://projectsapi.zoho.com/restapi/portal/[Portal ID]/projects/[Project ID]/tasklists/[Tasklist ID]/"
    type :GET
    connection: INSERT YOUR CONNECTION NAME
];
open_tasks = 0;
closed_tasks = 0;
total_tasks = 0;
tasks = response.get("tasks");
if(tasks.size() > 0)
{
    rows = List();
    for each  task in tasks
    {
        status = task.get("status").get("type");
        row = Map();
        row.put("Name",task.get("name"));
        row.put("Owner",task.get("details").toMap().get("owners").toMap().get("name"));
        row.put("Percentage Completed",task.get("percent_complete"));
        if(rows.size() <= 10)
        {
            total_tasks = total_tasks + 1;
            rows.add(row);
            if(status.equals("open"))
            {
                open_tasks = open_tasks + 1;
            }
            else
            {
                closed_tasks = closed_tasks + 1;
            }
        }
    }
}
text = {"text":"Task list for this week:","bot":{"name":"Report Bot","image":""},"card":{"title":"Task List","theme":"modern-inline"},"slides":{{"type":"label","title":"","data":{{"Open Tasks":open_tasks},{"Closed Tasks":closed_tasks}}},{"type":"table","title":"Task Details","data":{"headers":{"Name","Owner","Percentage Completed"},"rows":rows}}}};

// Scheduler is executed to post message to the #updates channel. "updatesm" is the channel unique name.
zoho.cliq.postToChannel("updatesm",text);

Trial Run 

Once the scheduler is created, click on the Trial Run option in the scheduler preview page to check the scheduler's working! Take a look at this GIF on how to try the working of the scheduler using the Trial Run option. The Task Status scheduler is executed to get the list of tasks and their details from Projects and post the response in the #updates channel.

 

Using Cliq DB tasks in schedulers

To access database tasks through schedulers, 1. Create a connection using Zoho OAuth and enter the scope as ZohoCliq.StorageData.ALL 2. Once after the connection is created use the connection name in your database task.

Sample Syntax


zoho.cliq.getRecords(<database_name>,<values_map>,<connection_name>);


 


Related Articles:

Cliq Schedulers: Configure a scheduler or ten to manage work effortlessly!

This forum article talks about how you can easily configure a scheduler to get notified about your tasks in Todoist.