Tip 24: How to generate a file preview in a report without downloading it.

Tip 24: How to generate a file preview in a report without downloading it.

Hi folks,


This month we will teach you how to preview a report file before sending it to someone or sending it for approval. While viewing reports in Zoho Creator, users cannot access or preview files uploaded through the File Upload field without downloading them. 

 

In this tip, we'll show you a way to do this.




Key concept:

The best way to achieve this function is to preview the uploaded file's content using the Add Note field in a stateless form (pop-up window) based on the record ID.  


Use case:

Let's use the example of Candidates applying for a job, where candidates have to fill in their details using the Job Application form. Their information will be displayed on the Candidates Details report, a list report with a button on every record. The admin can use these buttons to preview resumes without downloading them.

Application flow:

 

1. Candidates enter their information using the Job Application form.
2.  Whenever the admin accesses the Candidates Details report, they can preview all the submitted resumes with the click of a button.

Requirements:
  1. A Job Application form with fields Name, DOB, Contact Number, and Resume (File Upload field)
  2. A Stateless form (Please refer to the help article here to learn how to create a stateless form.)
  3. A Candidates Details report to view all the candidate information
  4. Custom action buttons to preview the resumes


Step 2: Create the stateless form with the following fields:
  • Parent Record ID:  Number Field  
  • Notes: Add Notes Field
NOTE: Please ensure that the maximum digits allowed in the Number field is 19 as we will be using this field to store record ID values for Zoho Creator. These will be 19-digit numbers.

Step 3: Create a custom action button for each record to open the stateless form
Follow the steps below to create a custom action that will help you pass the current Record ID as a parameter to the Number field in the stateless form.
  1. Edit the application.
  1. Access the Candidate Details Report.
  1. Click Edit this application.
  1. Click Configure Fields for Web.
  1. Click Add Fields, then select Add New Button.







Configure the button by clicking Create a new function with the code below.
  1. Void preview_function(int id1)
  1. {
  1. openUrl("#Form:<Stateless_Form>?<Number>=" + input.id1,"popup window");
  1. }
where,
Stateless_Form - The link name of the target stateless form
Number - Deluge name of Number field on the stateless form
id1 - argument to be associated with the ID of the actual form

Now, let's associate id1 as an argument to the Record ID.


The function above would open the stateless form and pass the current Record ID value to the Number field in the stateless form.
Step 4: Create a workflow to preview the uploaded file using the stateless form
Let's create a workflow based on the stateless form to fetch the file related to the Report ID, which is passed as a parameter to the Number field as mentioned below. 

Configure the code below in the On Load workflow of the Preview Data form (stateless form).
  1. Hide <Number>; 
  1. fetch_file = <Form>[ID == input.<Number>].<File>.content;
  1. Input.<Notes_Field> = fetch_file;
where,
Form - the form in which the file exists
Number - Number field in the Stateless form
File - the File Upload field in the Job Application form
Note: We are hiding the Number field using the "hide <field_name>" syntax. It's used to populate IDs for backend validations, which shouldn't be visible when the user accesses the form.

Step 5: Configuring the button with a workflow to close the pop-up window
As we all know, by default, a stateless form would have two button options:

1. Submit
2. Refresh

Since we are not going to perform any form submissions, we can delete that option. Then, we can add a new button and name it "Close." This can be used to close the pop-up window that will open to preview the file.

Create a workflow of the form Stateless > Button Click > Close.
  1. openUrl("#script:window:close,"same window");
Note: This can be used for the file upload field data of a type file. If you like to preview images, you can use Image fields. 
File types that usually contain only text values (for example, .txt, .csv, etc.) will return the content accurately. File types that usually contain images (for example, .pdf, etc.) will return junk values.

We hope this tip was interesting for you. If you have any questions, feel free to ask in the comments below, and we'll be happy to address them soon!











                            Zoho Desk Resources

                            • Desk Community Learning Series


                            • Digest


                            • Functions


                            • Meetups


                            • Kbase


                            • Resources


                            • Glossary


                            • Desk Marketplace


                            • MVP Corner


                            • Word of the Day



                                Zoho Marketing Automation


                                        Manage your brands on social media



                                              Zoho TeamInbox Resources

                                                Zoho DataPrep Resources



                                                  Zoho CRM Plus Resources

                                                    Zoho Books Resources


                                                      Zoho Subscriptions Resources

                                                        Zoho Projects Resources


                                                          Zoho Sprints Resources


                                                            Qntrl Resources


                                                              Zoho Creator Resources


                                                                Zoho WorkDrive Resources



                                                                  Zoho Campaigns Resources

                                                                    Zoho CRM Resources

                                                                    • CRM Community Learning Series

                                                                      CRM Community Learning Series


                                                                    • Tips

                                                                      Tips

                                                                    • Functions

                                                                      Functions

                                                                    • Meetups

                                                                      Meetups

                                                                    • Kbase

                                                                      Kbase

                                                                    • Resources

                                                                      Resources

                                                                    • Digest

                                                                      Digest

                                                                    • CRM Marketplace

                                                                      CRM Marketplace

                                                                    • MVP Corner

                                                                      MVP Corner

                                                                    





                                                                    




                                                                        Design. Discuss. Deliver.

                                                                        Create visually engaging stories with Zoho Show.

                                                                        Get Started Now