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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Set Powerapps screen b...
Power Apps
Unanswered

Set Powerapps screen based on a filter condition

(0) ShareShare
ReportReport
Posted on by

Is it possible to display the default screen of powerapps based on logged-in user's email address?

 

I have condition like below.  If there is at least 1  record on the Sharepoint list's "EmployeeEmail" column value equal to logged-in user's email address, I want to display a different screen and if not, a different screen.  

 

Where and how can I handle that? 

 

CountRows(Filter('Equipment Return Tracker' ,EmployeeEmail=User().Email))

Categories:
I have the same question (0)
  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    App.OnStart:

    Set(varUser,User());

    Set(IsUser,LookUp('Equipment Return Tracker' ,EmployeeEmail=varUser.Email));

    If(IsBlank(IsUser),Navigate(Screen1),Navigate(Screen2));

     

    The above code will store your logged in user's info into varUser. 

    Then go to your list and compare that against the whole list. If it find any record it will store it in the variable named IsUser. Then it will check if IsUser is blank or not. If it is blank it will navigate accordingly

  • TheRobRush Profile Picture
    11,128 Moderator on at

    In onstart of app you would throw out a if (countrows (where user email is on the list ) >=1), navigate to screen 1, navigate to screen 2)

  • Verified answer
    zmorek Profile Picture
    3,272 on at

    You can do it OnStart of the app:

     

    If(CountRows(Filter('Equipment Return Tracker' ,EmployeeEmail=User().Email))>0, Navigate(Screen),false)

     

    I typed that freehand, so please watch for parenthesis, punctuation, etc.

  • MarvinBangert Profile Picture
    1,924 Most Valuable Professional on at

    Hey @Anonymous 

    you can use the "App" - "On Start" property/functionality to check on app start if the condition "countrows()" is equals 0 or not, if yes, navigate to screen 1, if no, navigate to screen 2.

     

    Best regards
    Marvin

    If you like this post, give a Thumbs up. If it solved your request, Mark it as a Solution to enable other users to find it.

  • Guz_90 Profile Picture
    47 on at

    Hello , when I try to do what everybody suggest:

    If(IsBlank(CurrentUser), Navigate(MainMenuScreen_1,ScreenTransition.None))

    I get:

    "Navigate is not permitted in OnStart. Use the StartScreen property instead."

     

    if I try to put the conditional in StartScreen it says that global variables are not available from StartScreen property. After that I try to put the condition with the navigate in the OnVisible property of the screen I put in StartScreen but that is not allowed either ...any ideas or suggestions ?

  • TheRobRush Profile Picture
    11,128 Moderator on at

    @Guz_90 Since this post was made start page navigation has transitioned to StartScreen Property. You can rea more about how it works Here and if you have any questions set up a post, or let us know and we can try and help you out. Formula doesn't change much but no longer needs Navigate() as you just reference the page directly

  • jakub_podlaha Profile Picture
    21 on at

    Hello @TheRobRush

    thank you for pointing out the blog explaining the issue. But the problem @Guz_90 stated still holds. Following formula: 

    App.StartScreen = If(CountRows(MyCollection) >= 1; OneScreen; AnotherScreen)

    does not work (shows error) since collections can not be referenced from StartScreen property. 

     

    Since we can no longer Navigate from App.OnStart, and we can not reference collections or variables from App.StartScreen we're left with no way to navigate upon app start based on a collection content. How do we solve this? 

     

    I also tried to put following logic into OnVisible on the start screen: 

    App.OnStart = Set(IsFirstStart; true);;
    OneScreen.OnVisible = If
    (And(IsFirstStart; CountRows(MyCollection) >= 1; Navigate(AnotherScreen));; Set(IsFirstStart; false);;

    // If unsetting the IsFirstStart variable doesn't happen after the Navigate call we can always unset it on the next screen
    AnotherScreen.OnVisible = Set(IsFirstStart; false);;

    But the app rejects to do that too, stating it would "always navigate from the screen", which is clearly not true and also if the screen is a splash screen it is intentional to always navigate away from it... The limitation here seems unnecessary and blocking an intentional functionality. 

     

    I do undestand the reasoning to do whatever it takes to show the first screen as soon as possible for UX reasons. But this could simply be a splash screen intednded to be navigated from. But how? 

     

    Thanks,

    Jakub

     

    PS: I got straight to this post searching for this very problem, so it feels correct to post the solution here. 

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Not really sure what you are trying to do the navigate based on but you should just check whatever data you get your collection from in the first place. Also

    If(CountRows(MyCollection);

    this is not a boolean check, If(countrows(data), true, false) is always true, because you are just saying If I counted this then true, but by virtue of having typed CountRows() you have counted it, even if the result was 0 you still counted it So its true, every time. Should be more like

    If(!IsEmpty(Filter(originalDataSource,Title="Rob")), dataExistsScreen, defaultScreen)

     

  • jakub_podlaha Profile Picture
    21 on at

    Thanks for your reply. I fixed my obvious mistake in the example code. The boolean check is correct in my code, I just misstyped it in the post. Sorry for that. Let's not get distracted by it. The rest holds. 

    • Can not Navigate in OnStart function
    • Can not use/reference collection in StartScreen expression
    • Can not use Navigate in OnVisible function

    How shall I Navigate upon app start based on collection data fetched in OnStart then? 

     

    Edit: 

    Your code fails too. Following expression in StartScreen fails with error like "Can not use collection in StartScreen" property with "originalDataSource" highlighted. 

    If(!IsEmpty(Filter(originalDataSource,Title="Rob")), dataExistsScreen, defaultScreen)

     

  • TheRobRush Profile Picture
    11,128 Moderator on at

    originalDataSource was just an example text, if you have included it in your actual code it would fail. What is your collection made from, you need to base your formula on this, not the collection.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard