Custom Schedulers
Custom Schedulers in Zoho Subscriptions let you schedule frequent tasks and provide you with various recurrence options like selecting the date, time and frequency, in which your tasks are executed.
Scenario: Peter runs a cloud-based software company and has set a monthly target of $1000, for everyone in his sales team. At the end of every month, he goes through the Sales by Salesperson report to make a list of the salespersons who’ve exceeded their targets, to congratulate them. With Custom Schedulers, he can schedule a custom task, which automatically sends him a list of all the salespersons who’ve achieved their targets at the end of every month.
Note: This feature is available only in the Professional plan of Zoho Subscriptions.
ON THIS PAGE
Creating Custom Schedulers
To create a custom scheduler:
Go to Settings > Automation > Custom Schedulers.
Click + New Custom Scheduler.
Enter a Name for your scheduler.
Set the Frequency in which you want the scheduler to be executed.
You can configure schedulers to run daily, weekly, monthly or yearly. Here are the various recurrence settings, which will be available, based on the frequency that you set:
Daily: By default, the tasks will be executed everyday. However, you can also configure it to run based on a particular number of days, instead of being executed daily. An option to prevent the scheduler from running on weekends is available as well.
Weekly: The tasks will be executed once a week or once every couple of weeks, based on your settings. You can also configure the scheduler to run on a particular day of the week or on multiple days of the week.
Monthly: With this frequency, your tasks will be executed every month (based on your frequency settings). Your tasks can also be scheduled to run on a specific day or date.
Yearly: Your tasks will be executed year-wise, based on the recurrence period. For example, the task can be executed on the first Sunday in January or just January 5.
Warning: The start date of a scheduler cannot be more than one year from the date of creation.
Configure your custom scheduler’s expiration settings, which could either be after a particular date, a set number of executions or set to never expire at all.
Write your custom tasks using Deluge in the Deluge script editor.
Insight: Deluge (Data Enriched Language for the Universal Grid Environment) is an online scripting language that’s integrated with Zoho applications. It enables you to write your own functions to modify an application to suit your needs, making it more powerful and robust.
- Click Save or Save and Execute.
Now, your custom scheduler will execute the tasks based on your frequency settings.
Note: You can create a maximum of 10 custom schedulers.
Sample Function
Here’s an example of what a Deluge custom task would look like for the scenario above.
organizationID = organization.get("organization_id");
name = user.get("name");
userEmail = user.get("primary_email");
authtoken = "<ENTER AUTHTOKEN HERE>";
salesDetails = getUrl("https://subscriptions.zoho.com/api/v1/reports/salesbysalesperson?organization_id=" + organizationID + "&authtoken=" + authtoken + "&from_date=" + toStartOfMonth(today).toString("YYYY-MM-dd") + "&to_date=" + eomonth(today,0).toString("YYYY-MM-dd")).get("sales").toList();
salesPersonList = List();
for each sales in salesDetails
{
salesPersonName = sales.get("salesperson_name");
if(salesPersonName.equals("Others"))
{
continue;
}
amount = sales.get("sales_with_tax");
if(amount > "<ENTER AMOUNT>")
{
salesPersonMap = Map();
salesPersonMap.put("salesperson_name", salesPersonName);
salesPersonMap.put("amount", amount);
salesPersonList.add(salesPersonMap);
}
}
if(!salesPersonList.isEmpty())
{
mailMessage = "Dear " + name + ",<br>";
mailMessage = mailMessage + "Here's a list of salespersons who achieved their monthly target. <br><br> SalesPersonName - Sales Amount (With Tax) ";
for each salesperson in salesPersonList
{
mailMessage = mailMessage + "<br> "+ salesperson.get("salesperson_name") +" - "+ salesperson.get("amount");
}
}
sendmail
[
from :zoho.adminuserid
to : userEmail
subject :"Monthly Update: Sales Team Targets"
message : mailMessage
]