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.
Steps to follow
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 | Workers Report Name Number of Shifts Worked Wage
| Workers_Report Name Number_of_Shifts_Worked Wage
|
Currency | Total Wage | Total_Wage |
3.Click Add New Action > Deluge Script, and save the following Deluge snippet in the Deluge editor.
- // HOUSE KEEPING WAGES
- // Define a variable to calculate total house keeping wage
- total_wage = 0;
- // Create a collection to store subform values
- workers_collection = Collection();
- //Iterate the Contract Employees form to populate the subform rows and calculate total wage.
- for each worker in Contract_Employees[Department == "House Keeping" && Added_Time == zoho.currentdate]
- {
- row = Daily_Wages.Workers_Report();
- row.Name=worker.Name;
- row.Number_of_Shifts_Worked=worker.Number_of_Shifts_Worked;
- row.Wage=worker.Total_Wage;
- total_wage = total_wage + worker.Total_Wage;
- workers_collection.insert(row);
- }
- //Insert a new record into Daily Wages form
- record_id = insert into Daily_Wages
- [
- Added_User=zoho.loginuser
- Agency="Zylker - House Keeping"
- Date_field=zoho.currentdate
- Workers_Report=workers_collection
- Total_Wage=total_wage
- ];
- // SECURITY WAGES
- // Repeat the same steps for calculating total wages report of Security department
- total_wage = 0;
- workers_collection = Collection();
- for each worker in Contract_Employees[Department == "Security" && Added_Time == zoho.currentdate]
- {
- row = Daily_Wages.Workers_Report();
- row.Name=worker.Name;
- row.Number_of_Shifts_Worked=worker.Number_of_Shifts_Worked;
- row.Wage=worker.Total_Wage;
- total_wage = total_wage + worker.Total_Wage;
- workers_collection.insert(row);
- }
- record_id = insert into Daily_Wages
- [
- Added_User=zoho.loginuser
- Agency="Zylker - Security"
- Date_field=zoho.currentdate
- Workers_Report=workers_collection
- Total_Wage=total_wage
- ];
5. Click Add New Action > Deluge Script, and save the following Deluge snippet in the Deluge editor.
- sendmail
- [
- from: zoho.adminuserid
- to: "admin@zylker.com"
- subject: "Daily Labour Report"
- message: "Please find the PDF attached of Daily Labour Report"
- attachments:view:All_Daily_Wages [Date_field==zoho.currentdate] as PDF
- ]
See how it works
- Schedule
- Subform insert Deluge task
- Send mail Deluge task
- Add record Deluge task