web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Implement Role Based D...
Power Apps
Unanswered

Implement Role Based Display of Data

(0) ShareShare
ReportReport
Posted on by 6,048 Super User 2024 Season 1

Q1.png

My requirements:

1: Create Roles.

2: Only a manager from "Ahd-a" office can see his office's list of employees. Not other offices.

3: A director level person can see all list of employees from all offices.

Categories:
I have the same question (0)
  • RusselThomas Profile Picture
    4,014 on at

    Hi @zmansuri ,

    There are a few ways to achieve this, and of course your requirements and situation would typically dictate the best.

    Here is a fairly generic approach, which may or may not be applicable but should give you a start;

     

    If your role-based requirements are for filtering only (not access or privilege), then you need to have these references in your data so you can filter appropriately.

    Each row needs to provide information to your app that it can use to determine whether it is relevant to the current view or not - so in your example

    "2: Only a manager from "Ahd-a" office can see his office's list of employees. Not other offices."

    The employee records you're currently using would need to have a data element that identified their office.

     

    If they do, then you can start by creating a table that stores role information.  You can create a screen with a simple gallery/form combo for admins to review and/or edit this table from inside your app.

     

    You can include an actual 'role' if you like, but in this example if your office is "All" then your role can be assumed to be Director anyway;

    NameuserEmailRoleOffice
    Bobbob@home.comOffice ManagerAbad-A
    Harryharry@home.comOffice ManagerTraining
    Suesue@home.comDirectorAll

     

    You can then create an app-start expression that determines whether the current user is a manager and what office they are a manager for, which would allow you to apply the relevant filters on your galleries and data.

     

    Setting a global variable based on looking up the table above will allow you to set your galleries to automatically filter based on the variable, either according to the users office, or role, or role and office - however you want to do it.

     

    PLEASE NOTE:

    If your data is being stored on SharePoint and this is just for some handy app filtering, this is fine - however if you need to restrict people from seeing data, use data access control or a closed data source like SQL, otherwise users can just browse to the SharePoint list and view the data directly without any filters.

     

    Hope this helps,

     

    RT

  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    Can you please explain with step by step instruction. I am new at PowerApps and don't wanna mess my first job task. Thank you. 

    PS: This is the current code on Dropdown:

    If(
    LookUp(
    'Mitaja Employees',
    Lower('Mitaja Email') = Lower(User().Email),
    'Office Location'.Value
    ) = "All",
    [
    "All",
    "Abad-A",
    "Abad-B",
    "Hyd-A",
    "HeadQuater",
    "Training",
    "siyana",
    "Jolly"
    ],
    LookUp(
    'Mitaja Employees',
    Lower('Mitaja Email') = Lower(User().Email),
    'Office Location'.Value
    ) = "Abad-A",
    ["Abad-A"],
    LookUp(
    'Mitaja Employees',
    Lower('Mitaja Email') = Lower(User().Email),
    'Office Location'.Value
    ) = "Abad-B",
    ["Abad-B"],
    LookUp(
    'Mitaja Employees',
    Lower('Mitaja Email') = Lower(User().Email),
    'Office Location'.Value
    ) = "Hyd-A",
    ["Hyd-A"],
    LookUp(
    'Mitaja Employees',
    Lower('Mitaja Email') = Lower(User().Email),
    'Office Location'.Value
    ) = "HeadQuater",
    [
    "All",
    "Abad-A",
    "Abad-B",
    "Hyd-A",
    "HeadQuater",
    "Training",
    "siyana"
    ],
    LookUp(
    'Mitaja Employees',
    Lower('Mitaja Email') = Lower(User().Email),
    'Office Location'.Value
    ) = "Training",
    ["Training"],
    LookUp(
    'Mitaja Employees',
    Lower('Mitaja Email') = Lower(User().Email),
    'Office Location'.Value
    ) = "siyana",
    ["siyana"]
    )

    =======================================

    And this is the current code on Gallery items filed:

    If(!IsBlank(SearchBox.Text),Search('Mitaja Employees',SearchBox.Text,"FirstName","LastName"),Filter('Mitaja Employees','Office Location'.Value=drpOffice.Selected.Value||drpOffice.Selected.Value="All",Status.Value=drpStatus.Selected.Value||drpStatus.Selected.Value="All",DeptType.Value=drpDeptType.Selected.Value||drpDeptType.Selected.Value="All"))

  • RusselThomas Profile Picture
    4,014 on at

    Hi @zmansuri ,

    There are way too many moving parts to reliably 'edit' existing code, even when you're experienced, not to mention when you're just starting out, on anything you haven't created yourself. 

    Just looking at the code highlights potential pitfalls that can create more problems than we'll solve if we change something and it goes wrong because there's some other unseen mechanism at play in your app or your data.

     

    I would strongly suggest you try and enlist the help of someone professionally to work through this with you and help you deliver an outcome that keeps the rest of your solution integrity intact.     

     

    Kind regards,

    RT

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 421

#2
WarrenBelz Profile Picture

WarrenBelz 345 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 278 Super User 2026 Season 1

Last 30 days Overall leaderboard