Extract contents of a ZIP file and email the extracted files

Extract contents of a ZIP file and email the extracted files


Use Deluge to extract a ZIP file and email the extracted files with the click of a button.

Use Case  

An HR management application contains three forms: Add Employee , Employee Payslips , and Download My Payslips . The Add Employee form maintains the profiles of all employees. The Employee Payslips form is used to store payslips of all employees. At the end of each year, the HR (admin) uploads payslips of all employees as zip files into the Employee Payslips form. This form is accessible only by the admin. However, the employees can get their payslips using the Download My Payslips stateless form. When an employee requests for a payslip using the form, the selected month's payslip will be extracted from the zip file of the selected year (stored in Employee Payslips form) and sent as an email to the employee's email address.

Steps to follow  

1. Create two forms with the following details.
Form Link Name
Field Name
Field Link Name
Field Type
Add Employee
Official Email
Employee ID
This use case requires only the above-mentioned fields. You can include as many fields as required.
Employee Payslip
Employee Email
  • Year
  • Payslip ZIP
  • Year_field
  • Payslip_ZIP
  • Number
  • File Upload
Download My Payslip ( Stateless form )
Employee ID
Lookup (Add_Employee)
Enter Year
Select Month
( import predefined choices for Months of the year )
We have created the Download My Payslip form as stateless because we do not require the data provided to the form be stored in the application.
In order to create a stateless form , you will need to create a regular form  with required fields and duplicate the form with the "Data will be stored in Zoho Creator" checkbox unchecked.
2. Remove the Submit and Reset default buttons and add a button named Get Payslip in the Download  My  Payslip stateless form. You can also choose to retain the Reset button , if required.
3.  Create workflow  with the following details.

4. Save the following script in the Deluge Editor:
  1. // Disable field
  2. disable Employee_ID;

  3. // Assign the record ID of the logged in employee's record in Add_Employee form to the Employee_ID lookup field
  4. input.Employee_ID = Add_Employee[Official_Email == zoho.loginuserid].ID;

5. Create a connection to Zoho Creator service named "creator_oauth_connection". This connection will be used in the Deluge script in step 7  to download file.
6.  Create another workflow with the following details.
7.  Click Add New Action and select Deluge script. Save the following Deluge script in the Deluge editor:
  1. // Fetch employee record of the logged in employee from Employee_Payslip Form
  2. empRecord = Employee_Payslip[Employee_Email == zoho.loginuserid];

  3. //Iterate through the subform that holds employee's payslips as zip files 
  4. for each subformRow in empRecord.Payslips
  5. {

  6.  //Find the subform row that holds the payslip zip file of the requested year
  7.  if(subformRow.Year_field == Enter_Year)
  8.  {

  9. //Download the requested year's payslip zip file using Zoho Creator V2 API
  10. //Replace <app_admin_name> and <application_link_name> with appropriate values
  11. zip_file = invokeurl
  12. [
  13. url :" https://creator.zoho.com/api/v2/<app_admin_name>/<application_link_name>/report/All_Employee_Payslips/" + empRecord.ID + "/Payslips.Payslip_ZIP/" + subformRow.ID + "/download"
  14. type :GET
  15. connection:"creator_oauth_connection"
  16. ];

  17. // Extract the zip file to get pdf files containing payslip of individual months
  18. extractedFiles = zip_file.extract();

  19. //The extracted files are returned as Map in which the keys are file name and values are their corresponding pdf file
  20. //Assuming the file names are stored in the format EmployeeID-Month-Year.pdf, construct file name of the requested payslip
  21. fileName = input.Employee_ID.Employee_ID + "-" + input.Select_Month + "-" + input.Enter_Year + ".pdf";

  22. /Get the required payslip from the extracted file
  23. requestedFile = extractedFiles.get(fileName);

  24. //Send the requested payslip as mail
  25. sendmail
  26. [
  27.  from :zoho.adminuserid
  28.  to :zoho.loginuserid
  29.  subject :"Payslip" + "-" + input.Select_Month + " " + input.Enter_Year
  30.  message :"Please find your requested payslip in the attachments"
  31.  Attachments :file:requestedFile
  32. ]

  33. //Display an acknowledgement message
  34. alert "The requested payslip has been sent as email";
  35.  }

See how it works

Points to note  

  • The Deluge script provided in this tutorial is specific to the ZIP files that contai s 12 PDF files each corresponding to months of a year. For the script to work as expected, the filenames of the PDF files must be in the format: <employeeID>-<month>-<year>.pdf .

    Example: 2406-January-2020

    Please check the attachments for the sample file on which the provided Deluge script works.  

    Zoho CRM Training Programs

    Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

    Zoho CRM Training
      Redefine the way you work
      with Zoho Workplace

        Zoho DataPrep Personalized Demo

        If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

        Zoho CRM Training

          Create, share, and deliver

          beautiful slides from anywhere.

          Get Started Now

            Get started with Zoho Sign

            in a few quick steps!

            Download Help Guide

                        Still can't find what you're looking for?

                        Write to us:  support@zohoforms.com



                          Zoho Marketing Automation

                            Zoho Sheet Resources


                                Zoho Forms Resources

                                  Secure your business
                                  communication with Zoho Mail

                                  Mail on the move with
                                  Zoho Mail mobile application

                                    Stay on top of your schedule
                                    at all times

                                    Carry your calendar with you
                                    Anytime, anywhere

                                          Zoho Sign Resources

                                            Sign, Paperless!

                                            Sign and send business documents on the go!

                                            Get Started Now

                                                Zoho SalesIQ Resources

                                                    Zoho TeamInbox Resources

                                                            Zoho DataPrep Resources

                                                              Zoho DataPrep Demo

                                                              Get a personalized demo or POC

                                                              REGISTER NOW

                                                                Design. Discuss. Deliver.

                                                                Create visually engaging stories with Zoho Show.

                                                                Get Started Now

                                                                                      • Related Articles

                                                                                      • Update a form using custom action (from another form's report)

                                                                                        Requirement   Update a form using a custom action configured in another form's report. Use Case In an engineering college student management application, a student may withdraw at any time of the academic year. Whenever a student applies for ...
                                                                                      • Update an existing record using stateless forms

                                                                                        Requirement   Use details specified in a stateless form to modify records in the main form. Use Case   In an order management system, a customer has placed an order and wants to cancel it. The administrators allow for cancellation by accepting the ...
                                                                                      • Disable Custom Actions after n times

                                                                                        Requirement  A custom action on a report has to be disabled after it is triggered three times. Use Case  We have an app to maintain customer invoices. After an invoice is created, the staff can email the invoice to the customer with the click of a ...
                                                                                      • Custom access permissions for app users

                                                                                        Requirement Create custom permissions for an application and assign them to relevant users. Use case In a human resources management application, users need to be assigned with different access levels, based on their designation. For example, ...
                                                                                      • Display custom action button for specific records

                                                                                        Requirement   The custom action button in a report should be visible only for certain records, based on a condition. Use Case   An asset request app lets employees raise requests for gadgets or machines. While filling the form, employees can specify ...
                                                                                      Wherever you are is as good as
                                                                                      your workplace



                                                                                        Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.


                                                                                        Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.


                                                                                        Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.

                                                                                        CRM Tips

                                                                                        Make the most of Zoho CRM with these useful tips.

                                                                                          Zoho Show Resources