Function Inputs in Report Filter

Function Inputs in Report Filter

Is it possible to pass a field into a function in a report filter? I have a use case where employees are broken out into different branches based on geographical region, however there are certain regional managers that reside over multiple branches. I'd like to filter a Deals report where account managers can only see their own deals, servicing managers can see all deals in the branch, and regional managers can see all deals in each branch they manage.

The inspiration to use a function to filter a report comes from this post: Creator App: Customer Portal Adding Companies, Company Branches and Employees (zoho.com). The thing I need to change is I would need a multiselect from the users to the branch form lookup since some employees can be assigned to multiple branches.

I have created separate users and branch forms with bi-directional multi-select lookups. In the Deals form, I have a Branch lookup dropdown field that I will use to match against the function. I am then using deluge to add the Branch based on the account manager's assigned branch. I created a deluge function that takes in a Branch ID, gets all branches for the logged in user, and returns the Branch ID if one matches (otherwise returns 0). This way if I were able to pass the Deal's Branch lookup field in the report filter into the function, I'd be able to filter for one or more branches.

Deal report filter:
  1. Blueprint_Stage == "Account Manager Review" && Branch.ID == thisapp.UserFunctions.getMatchingUserBranch(input.Branch)
  1. I tried setting the function argument as Branch.ID, but I got errors when loading the report. By putting in Branch, it auto-corrects it to input.Branch when I save the filter.

UserFunctions.getMatchingUserBranch definition:
  1. int UserFunctions.getMatchingUserBranch(int BranchID)
  2. {
  3. branchList = Users[Zoho_User == zoho.loginuser].Branch;
  4. for each userBranch in branchList
  5. {
  6. if(userBranch == BranchID)
  7. {
  8. return BranchID;
  9. }
  10. }
  11. return 0;
  12. }
In the report, I'm not getting any errors, but I'm also not getting any records that match the criteria. I know this is a complex case. Please let me know if I need to further clarify anything or if there is another solution entirely to this problem!
    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


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




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方