Role based Access On Page

Hi All

I’m working out how to incorporate the Role-based Page access in my dashboard. To give you some context. I have certain pages that only should be accessed when meeting certain criteria, this created 3 roles. Employee, Owner, and Manager. Now to validate if a person accessing the Dashboard and its pages check as one of those roles a database query needs to happen. If I implement that query in the script pane of the role. I never seem to access that page. Even Explicitly adding myself as a true validation doesn’t help. I used the normal build-in variable $User as well as the alternative I’ve seen in videos $User.Identity.Name. If I just return $true all works fine. I assume something is up with using queries inside this script place. (Do not I tried with hardcoded values as well at no prevail). See below for some screenshots of how I tried to achieve this.

Note. Using the same query validates effectively that I am indeed an owner. Otherwise, I do not see the button to access this page ( behind the scene it is the same query) of course I would like to work with the $Role variable instead to prevent duplicate code.

Thank you for your time and effort!

Kind regards.

Product: PowerShell Universal
Version: 1.4.6