Filter report using dynamic values from a function

Filter report using dynamic values from a function

Requirement

When a user accesses a report, data is filtered based on the logged-in user's role so that only the required details are visible to the user.

Use Case

An employee management system has two forms, Department and Employees. The Department form has the list of various departments and the Employees form holds the details of employees. Multiple employees can belong to a department. In this application, when the head of a department logs in to the application, the employees in their department alone are listed for their perusal.

Steps to follow

1. Create the forms with the following details:

Form

Form Link Name

Field Type

Field Name

Field Link Name

Department

Department

Single Line

Department Name

Department_Name

Employees

Employees

Name

Name

Name

Lookup (Department)

Department

Department

Email

Official Email

Official_Email

Phone

Phone

Phone_Number


The Official Email field holds the email ID the employee uses to log in to the employee management application.
 
2) Let us now create a function to find the department of the current logged-in user. Create a function named getDepartment and select the return type int.
 
(Lookups are referenced based on the record link IDs of the relevant records in their base forms, so the return type of this function is int (number). This function is going to search employee reports to find employees based on this lookup value.)
 
3) Add the below code in the ensuing Deluge editor:
  1. int getDepartment()
  2. {
  3. //Fetch the department record based on login user email ID
  4. employee = Employees[Official_Email = zoho.loginuserid];
  5. return employee.Department;
  6. }
This function searches the employee records from the All Employees report based on the logged-in user's email ID. From the Employee record, the corresponding Department record's ID value is returned.
 
4) Add a filter to the All Employees report using the getDepartment function to match the ID in the Department form:
 


See how it works


Points to note

  • The Department field in the Employee form can be created as a picklist. In this case, the getDepartment function can return the Department value as a string directly and the filter can also be done. (Since integer comparison would be more optimal than string comparison, lookup was used in this example.) The sample code could be:
  1. string getDepartment()
  2. {
  3. return Employee [ Official_Email == zoho.loginuserid ].Department;

    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


            Zoho Sign now offers specialized one-on-one training for both administrators and developers.

            BOOK A SESSION








                                You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                    Manage your brands on social media

                                      Zoho Desk Resources

                                      • Desk Community Learning Series


                                      • Digest


                                      • Functions


                                      • Meetups


                                      • Kbase


                                      • Resources


                                      • Glossary


                                      • Desk Marketplace


                                      • MVP Corner


                                      • Word of the Day


                                        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 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







                                                                                            You are currently viewing the help articles of Sprints 1.0. If you are a user of 2.0, please refer here.

                                                                                            You are currently viewing the help articles of Sprints 2.0. If you are a user of 1.0, please refer here.



                                                                                                  • Related Articles

                                                                                                  • Building an employee dashboard

                                                                                                    Requirement   Create an employee dashboard with buttons that will help the employees to check in and out, find the total number of logged-in hours and apply for leave. Use Case   An Employee Management application has a dashboard for their employees. ...
                                                                                                  • Statistical values on a report based on numerical fields

                                                                                                    Requirement Display the common statistical results on the reports for the numerical fields in a form, to help in identifying trends and decision-making process. Use Case In any sales-based business, crunching numbers is a big task. An order ...
                                                                                                  • Dynamically Filter Lookup Options Based on Another Lookup Field's Selection

                                                                                                    Requirement Automate the creation of portal user accounts based on the email entered in the Zoho Creator form. Use Case Consider an IT asset management application on which an organization relies to register and monitor assets assigned to employees. ...
                                                                                                  • Appointment Management with Dynamic Drop Down

                                                                                                    Requirement   Allow patients to book appointments with their doctors. Use Case   A clinic wants to digitize its booking system. There are multiple specialists and different dates/times for appointments. Each appointment lasts for 30 minutes. There ...
                                                                                                  • Hotel management

                                                                                                    This app has been published in accordance with Marketplace review process. For pricing details, you can refer to this page. Category - Hospitality Vendor - Zoho Corporation Pricing - Free Overview Say goodbye to thick registry books and run your ...
                                                                                                    Wherever you are is as good as
                                                                                                    your workplace

                                                                                                      Resources

                                                                                                      Videos

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



                                                                                                      eBooks

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



                                                                                                      Webinars

                                                                                                      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