Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

User login based on User Rule using switch function

(1) ShareShare
ReportReport
Posted on by 8

Good day,

I hope I can get some guidance and answer on this one.

 

I'm getting error with my user role switch function with my login. 

I'm using switch function to validate the 'User Role' column in my SharePoint list

if it's "Superuser", "User", "Approver", and "Director". 

 

Please note that I used the choice type for 'User Role' column.

 

Please see attached picture of my code and where I'm getting an error.

Thank you in advanced folks!

  • pankajrana Profile Picture
    8 on at
    User login based on User Rule using switch function
    ​​​​​​​thanks this helped
  • rpatricio Profile Picture
    8 on at
    Re: User login based on User Rule using switch function

    Thank you @WarrenBelz and Noted with posting the codes in Text. Problem solved! All I needed was the .Value after the 'User Role'. Thanks again!

  • Verified answer
    WarrenBelz Profile Picture
    146,651 Most Valuable Professional on at
    Re: User login based on User Rule using switch function

    Hi @rpatricio ,

    Can you please remember to post your code in Text as it saves re-typing here. This code is OCR'd, so please watch spelling. I am not sure exactly what you are trying to do here - you seem to have a mixture of navigation functions and Table values - is this the structure you are attempting ?

    With(
       {
          _Role
          LookUp(
             tbl_logins,
             User().Email = txtUser.Text And Password = txtPass.Text
          ).'User Role'.Value
       },
       If(
          IsBlankOrError(_Role),
      Notify( "You don't have permission to login this account", NotificationType.Error ), Switch( _Role, "Superuser", Navigate(adminHomeScreen), "User", Navigate(userScreen), "Approver", Navigate(approverScreen), "Director", Navigate(directorScreen), Navigate(whateverScreen), ) )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,651 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard