Hello π
Here is a new issue I'm facing...
I'm trying to add an access control on some screens of my app, based on a global variable.
If this variable (boolean) is false, when a user open a specific page, I want it to be redirected to the homescreen.
I achieved this behaviour with a button that is selected with the OnVisible() property of the screen. If the variable is false, the button is selected and the OnSelect() property navigates to the home page.
I want to replicate this behaviour on multiple pages so I tought I could add an hidden button on my "Navigation menu" component and select it with the OnVisible() of each pages I want to add access control on.
The issue is that I have no idea how to Select() a button that is in a component or if there is another way to achieve what I want witout adding a button on each page I want this access control.
Thank you π
Hello Jedediah!
I had a similar difficulty today and managed to resolve it using the OnReset action of the component itself.
In your component's edit menu, configure OnReset to select the button that you configured as the Navigate function, but first add a Toggle to turn redirection on and off. This will ensure that your screen does not loop when you try to edit the screen:
// OnSelect of the button inside the component
Navigate(scn_Home;ScreenTransition.None)
// OnReset of the component itself
If(tgl_ActiveNavigate; Select(btn_NavigateTo); false)
Now go to the screen where you will add your component and add a new button. This button will be hidden and will be responsible for selecting the component's OnReset.
Now include the Reset() function in the OnSelect of the button that will be hidden:
Reset(cmp_scn__Navigate_To)
And lastly, configure the screen's OnVisible to select the button that will be hidden:
-----
This solution worked for me and I hope it works for you too! π
Note: I don't speak English (I'm Brazilian) and I used Google Translate, so I ask you to disregard any writing errors π .
Thanks for this idea but I really want to redirect them and I can achieve this using buttons. I'm just looking for an optimized way to avoid adding buttons en each pages.
Maybe, add container to your restricted pages. Container will be visible if user is not permited to view screen content, it will cover full app screen. You can place in this container notification for user and homescreen navigation button.
The variable is initialised in OnStart() : true if the user is in a specific group, false otherwise.
This variable is passed to the menu component to control the Visible() field of the menu items.
So a HR member will see the HR menu, an IT member will see the IT menu, etc.
With a basic usage of the app, when you access it with its URL, we have no issue since the users can't access restricted pages since they don't have a link to them in the menu.
I recently added deeplinks to allow me to send link to users to specific pages. With this usage comes a little risk that a user can access pages that they can't normally access. It is this specific issue that I wan't to address.
Since I have my variables that can tell me if the user is in a group or another, I would like to use them to add a ultimate check when sensitive pages are opened to redirect users to home page if they are not authorized to access those pages.
oh, you are right. I didnt know that.
Ok, lets try different approach then. How do plan to navigate the user to this specific screen where you want too check variable value?
Hello @Adam1986 π
I used a button because you can't use Navigate() in OnVisible() of a screen.
Hi @Jedediah,
Instead of using Button you should use OnVisible property of screen.
OnVisible:
If(
!yourBooleanVariable,
Navigate(
Homescreen,
ScreenTransition.Fade
)
)
So, if user opens specific screen, OnVisible of this screen will run and check if yourBooleanVariable is equal to false (notice there is !yourBooleanVariable). Then if this statement is true it will navigate user to homescreen. If yourBooleanVariable is equal to true i will do nothing.
Never use Select() to run something under other component. There is always easier way.
WarrenBelz
637
Most Valuable Professional
stampcoin
570
Super User 2025 Season 2
Power Apps 1919
473