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 ( 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 Marketing Automation

            Zoho Pagesense Resources

              Zoho SalesIQ Resources

                    Zoho TeamInbox Resources

                      Zoho DataPrep Resources

                        Zoho CRM Plus Resources

                          Zoho Books Resources

                            Zoho Subscriptions Resources

                              Zoho Desk Resources

                                Zoho Projects Resources

                                  Zoho Sprints Resources

                                    Qntrl Resources

                                      Zoho Creator Resources

                                        Zoho WorkDrive Resources

                                            Zoho Campaigns Resources

                                              Zoho CRM Resources

                                                      Design. Discuss. Deliver.

                                                      Create visually engaging stories with Zoho Show.

                                                      Get Started Now