Create daily reports and send as email attachment | Zoho Creator Academy

Automatically create daily reports and send current day's reports as email attachment

Requirement

Schedule custom actions to automatically create labour reports everyday at the specified time and send a filtered report of all the reports corresponding to the current day as an email attachment.

Use case

Let's assume your company has signed with a contract agency to employ maintenance teams. The contractors allocate workers and you will have to send them a labour report everyday. This process can be automated using the Zoho Creator's schedule feature. In an Employee Tracker application, information like number of shifts worked by a worker and labour charge per shift are maintained in the Contract Labour form. The Contract Labour form's records that correspond to the current day will be automatically consolidated and added as a record in the Daily Wages form. In addition, from the Daily Wages form, only the records corresponding to the current date will be sent as email to the contractor's email address. This process takes place everyday at the specified times.

See how it works

Steps to follow

1. Create two forms with the following details.

Form

Form Link Name

Field Type

Field Name

Field Link Name

Contract Employees

Contract_Employees

Name

Name

Name

Single Line

Department

Department

Number

Number of Shifts Worked

Number_of_Shifts_Worked

Currency

Wage Per Shift

Wage_Per_Shift

Currency

Total Wage

Total_Wage

Daily Wages

Daily_Wages

Single Line

Agency

Agency

Date

Date

Date_field

Subform

  • Name

  • Number

  • Currency

Workers Report

  • Name

  • Number of Shifts Worked

  • Wage

Workers_Report

  • Name

  • Number_of_Shifts_Worked

  • Wage

Currency

Total Wage

Total_Wage


2. Create a schedule with the following details:



3.Click Add New Action > Deluge Script, and save the following Deluge snippet in the Deluge editor.
  1. // HOUSE KEEPING WAGES
  2. // Define a variable to calculate total house keeping wage
  3. total_wage = 0;

  4. // Create a collection to store subform values
  5. workers_collection = Collection();

  6. //Iterate the Contract Employees form to populate the subform rows and calculate total wage.
  7. for each  worker in Contract_Employees[Department == "House Keeping" && Added_Time == zoho.currentdate]
  8. {
  9. row = Daily_Wages.Workers_Report();
  10. row.Name=worker.Name;
  11. row.Number_of_Shifts_Worked=worker.Number_of_Shifts_Worked;
  12. row.Wage=worker.Total_Wage;
  13. total_wage = total_wage + worker.Total_Wage;
  14. workers_collection.insert(row);
  15. }

  16. //Insert a new record into Daily Wages form
  17. record_id = insert into Daily_Wages
  18. [
  19. Added_User=zoho.loginuser
  20. Agency="Zylker - House Keeping"
  21. Date_field=zoho.currentdate
  22. Workers_Report=workers_collection
  23. Total_Wage=total_wage
  24. ];

  25. // SECURITY WAGES
  26. // Repeat the same steps  for calculating total wages report of Security department
  27. total_wage = 0;
  28. workers_collection = Collection();
  29. for each  worker in Contract_Employees[Department == "Security" && Added_Time == zoho.currentdate]
  30. {
  31. row = Daily_Wages.Workers_Report();
  32. row.Name=worker.Name;
  33. row.Number_of_Shifts_Worked=worker.Number_of_Shifts_Worked;
  34. row.Wage=worker.Total_Wage;
  35. total_wage = total_wage + worker.Total_Wage;
  36. workers_collection.insert(row);
  37. }

  38. record_id = insert into Daily_Wages
  39. [
  40. Added_User=zoho.loginuser
  41. Agency="Zylker - Security"
  42. Date_field=zoho.currentdate
  43. Workers_Report=workers_collection
  44. Total_Wage=total_wage
  45. ];
4. Create another schedule with the following details.



5. Click Add New Action > Deluge Script, and save the following Deluge snippet in the Deluge editor.
  1. sendmail
  2. [
  3. from: zoho.adminuserid
  4. to: "admin@zylker.com"
  5. subject: "Daily Labour Report"
  6. message: "Please find the PDF attached of Daily Labour Report"
  7. attachments:view:All_Daily_Wages [Date_field==zoho.currentdate] as PDF
  8. ]

See how it works


  1. Schedule
  2. Subform insert Deluge task
  3. Send mail Deluge task
  4. Add record Deluge task