Custom Schedulers

Custom Schedulers

Purpose

Custom Functions allows you to customize a lot of commonly used functions thereby helping you save time. Custom Scheduler is an add-on to the existing Custom Functions. Using the Custom Scheduler, you will be able to create a scheduler which will automatically perform the actions of a particular Custom Function, at the time specified by you. While custom functions will be triggered based on workflow actions, custom schedulers do not need any workflow actions for them to get triggered. 


Watch our Help Video on Custom Schedulers:


Configure Custom Scheduler

  1. From your home page, go to Settings (gear icon) > Employee Information > Automation > Scheduler > Custom Scheduler > Add Custom Scheduler.



  2. Click on Add Custom Scheduler.
  3. Give a Custom scheduler name and add a description if necessary.
  4. Give a Start date and time.
  5. Set Frequency.
  6. Under Time zone, select your desired time zone.
  7. In the Custom function editor, update the respective script.



  8. Click Save.
Notes
For Weekly scheduler, you will be able to select the day on which the schedule should run, by using the dropdown. For Monthly scheduler, you will have the option to select the date and for Yearly scheduler, you will be able to select the Month and Date on which the scheduler should run.

Example Scenario - Salary Processing

Consider a scenario where you need to update the Salary form based on the 27th of every month based on various other values like Mediclaim amount, other reimbursement amount etc. In this case, you can create a scheduler for this date, to take values from multiple forms to update your salary details form.
Follow the steps given below to do this.
Notes
You need to have the forms and fields used in the script available in your account for you to use this function.
  1. From your home page, go to Settings (gear icon) > Employee Information > Automation > Scheduler > Custom Scheduler > Add Custom Scheduler.
  2. Name the Scheduler "Reimbursement details". and add a description if necessary.
  3. Set the Start date and time as 27.
  4. Under Time, specify the desired time
  5. Under Frequency, select Monthly and under Dates, choose 27.
  6. In the Custom Function Editor, paste the script given below:

    Quote
    salarydetails = Map();
    salarydetails = zoho.people.getRecordById("Salary_reference",recordid);
    tabularmap = Map();
    tabularmap = salarydetails.get("tabularSections");
    tabularlist = List();
    tabularlist = tabularmap.get("Breakup details");
    salarymap = Map();
    Totalsalary = 0;
    for each r in tabularlist
    {
    salarymap = r.toMap();
    Totalsalary = salarymap.get("HRA1").toDecimal() + salarymap.get("Other_Allowance1").toDecimal() + salarymap.get("Medical1").toDecimal() + salarymap.get("Basic1").toDecimal();
    }
    salaryupdate = Map();
    salaryvalue = Map();
    salaryvalue.put("recordid",recordid);
    salaryvalue.put("Net_Salary",Totalsalary.toString());
    salaryvalue.put("Revised_date",today.toString());
    salaryupdate = zoho.people.update("Salary_reference",salaryvalue);
    info salaryupdate;
    This function will add salary details from salary reference form to the Monthly salary form.

    Quote
    getdata = List();
    getdata = zoho.people.getRecords("Salary_reference");
    addata = Map();
    addrecord = Map();
    This will iterate all the entries and update it to Salary details form on specifying current date.

    Quote
    for each r in getdata
    {
    mon_salary = r.get("Net_Salary");
    erecno = r.get("Employee_ID.ID");
    addata.put("Employee_ID",erecno);
    addata.put("Montly_Salary",mon_salary);
    addata.put("Date_1",today.toString());
    addrecord = zoho.people.create("Monthly_Salary_Details",addata);
    }
    putrecord = Map();
    updaterecord = Map();
    putrecord.put("recordid",recordid); putrecord.put("Sch_date",datevalue.toString());
    updaterecord = zoho.people.update("Schedular_form",putrecord);
    info updaterecord;

  7. Click Save.
Once this scheduler is created, a scheduler will be pushed on the 27th of every month to update the salary form based on details from other forms.