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 / global variables are n...
Power Apps
Answered

global variables are not allowed in start screen

(0) ShareShare
ReportReport
Posted on by 77

in my application I'm using AzureAD coneector for authentication- OnStart property is set to - 

 

If(
!IsEmpty(
AzureAD.CheckMemberGroupsV2(
User().Email,
["cfxxxxa0-7xx6-48x9-bxf3-xxxxxxxxxxx"]
).value
),
Set(
varAdmin,
true
),
Set(
varAdmin,
false
)
);

 

now what I want is - if the user does not belong to that particular Azure AD group he should be navigated to some error screen. and if he has access the home screen of the application should appear. 

I tried using below code on onstart screen property.  but I'm getting global variables are not allowed in start screen error

 

If(varAdmin = false, ErrorScreen, HomeScreen) ;

 

 

How am I suppose to redirect the user to the respective screens? 

 

Categories:
  • WarrenBelz Profile Picture
    156,730 Most Valuable Professional on at

    Hi @pranavj619 ,

    Unfortunately the long way, but this should work

    If(
     IsEmpty(
     AzureAD.CheckMemberGroupsV2(
     User().Email,
     ["cfxxxxa0-7xx6-48x9-bxf3-xxxxxxxxxxx"]
     ).value
     ),
     ErrorScreen, 
     HomeScreen
    )

     

    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.

    Visit my blog Practical Power Apps

     

  • Verified answer
    WarrenBelz Profile Picture
    156,730 Most Valuable Professional on at

    Hi @pranavj619 ,

    Just checking if you got the result you were looking for on this thread. Happy to help further if not.

    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.

    Visit my blog Practical Power Apps

  • pranavj619 Profile Picture
    77 on at

    Hi @WarrenBelz I tried using the code that you gave. But now my home screen is showing blank...and it is not navigating to the error screen which I wanted.

     

    Not sure what I'm doing wrong here

  • WarrenBelz Profile Picture
    156,730 Most Valuable Professional on at

    Hi @pranavj619 ,

    I simply used your code - if the test you provided is true, then it certainly will go to the error screen.

  • pranavj619 Profile Picture
    77 on at

    @WarrenBelz 

     

    If(
    !IsEmpty(
    AzureAD.CheckMemberGroupsV2(
    User().Email,
    ["cfxxxxa0-7xx6-48x9-bxf3-xxxxxxxxxxx"]
    ).value
    ),
    Set(
    varAdmin,
    true
    ),
    Set(
    varAdmin,
    false
    )
    );

     

     

    If I'm using this code...I'm be getting the boolean value...which I thought of using in the start screen...but it seems it is not working....when I replaced the variable thing with the screen names it not going anywhere....is there any alternate way where I can use the variable to navigate?

  • Verified answer
    WarrenBelz Profile Picture
    156,730 Most Valuable Professional on at

    Hi @pranavj619 ,

    Correct - it certainly should produce a Boolean true/false result, which will be reflected in the navigation options.

    Below is one I use which may be useful (I do not use AzureAD). Note I am not a fan of the StartScreen function either - if it was not broke, why fix it . . .

    With(
     {
     wID: LookUp(
     Office365Groups.ListOwnedGroups().value,
     id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
     ).id
     },
     If(
     User().FullName in Office365Groups.ListGroupMembers(wID).value.displayName,
     HomeScreen,
     ErrorScreen
     )
    )

     

    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.

    Visit my blog Practical Power Apps

     

  • pranavj619 Profile Picture
    77 on at

    @WarrenBelz Thanks for your input. In the end, I had to come up with a different approach, so that I don't have to go to other screen. I used my initial code where I'm setting up the varAdmin variable. I used this variable for the Visible property of my gallery.

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 360 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 325

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard