In today’s blog I will discuss how you can navigate screens dynamically based of name in Power Apps canvas apps.
Before I go ahead and suggest a solution, let’s understand the requirement here. Below I have a gallery showing the list of contacts. And say I have a requirement. And the requirement is, if I click on System Admin contacts, it will take me to admin edit screen and for other contacts it will go to regular screen.
We just have two screens here but imagine you have a plethora of screens and then you want to navigate to different screens based on business logic. Each of the items in the Gallery has a ScreenName property but I can’t use that because it’s a text property and Navigate function won’t accept that.
Then how can I do it? For that I create a collection of my app screens in App OnStart property.
Collect(
screens,
{
Id: "admin",
Screen: AdminScreen
},
{
Id: "regular",
Screen: RegularScreen
},
{
Id: "display",
Screen: DisplayScreen
}
)
And on click of the item in the Gallery, I use the following code.
Navigate(LookUp(screens, Id = ThisItem.ScreenName).Screen)
Observe I am using the ScreenName property to get the screen from the screens collection.
Hope this helps!
You will also like the below posts.
Debajit Dutta
Business Solutions MVP
Discover more from Debajit's Power Apps & Dynamics 365 Blog
Subscribe to get the latest posts sent to your email.