cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Can you setup a Gallery to select a Screen to navigate to?

Hi All,

 

I've setup a Home Screen Gallery and I'd like to setup the onselect to navigate to different screens.

 

I thought I'd have to put in something like 

 

Navigate(ScreenTitle.Selected, ScreenTransition.Fade)

 

It's not working though.

 

Thanks in advance for any help you can provide

 

Regards

 

 

Dave

1 ACCEPTED SOLUTION

Accepted Solutions


@Anonymous wrote:

I've also tried this in the Onselct field of the image within the Gallery I'm using as a button and still no luck. Error given "Invalid Argument Type"

 

 

If(
Title = "NHVAS Maintenance Minimum Checklist", Navigate(NHVASMaintenanceChecklist, ScreenTransition.Fade),
Title = "TruckSafe Minimum Checklist", Navigate(TrucksafeMinChecklist, ScreenTransition.Fade),
Title = "NHVAS and Trucksafe Minimum Checklist", Navigate(NHVASTrucksafeChecklist, ScreenTransition.Fade))


If you reduce the formula to its minimum:

If(Title = "NHVAS Maintenance Minimum Checklist", Navigate(NHVASMaintenanceChecklist, ScreenTransition.Fade))

Do you still see the error? If yes, then try to hover across the two parameters of the function, to see if the error has more information.

 

Do you not see the error? Then start adding the other options one at a time until you see an error; when you do, hover on the formula bar to see if you get more information about it.

View solution in original post

8 REPLIES 8
CarlosFigueira
Power Apps
Power Apps

You can do that, if you define the screen name (not a string containing the screen, that difference is important) as one of the items of the collection that you use for the gallery in the home screen.

 

If your collection is local, then you need to add a new item to it. For example, this is the (verbatim) value of the Items property of the gallery in the home screen for an app that I've built to use internally to manage DRI duties (some internal process we have in our team):

Table(
    {Title: "Before DRI", Screen: BeforeDRIScreen, Subtitle: "Things to do before you are a primary DRI"},
    {Title: "During DRI", Screen: DuringDRIScreen, Subtitle: "What to do during the week when you are the DRI"},
    {Title: "After DRI", Screen: AfterDRIScreen, Subtitle: "What to do to ensure a good transition to the next DRI"})

In my app I have 4 main screens (there are also others, but it doesn't matter for this example): HomeScreen, BeforeDRIScreen, DuringDRIScreen, AfterDRIScreen. The OnSelect property of the controls within the gallery template is set to the following:

Navigate(ThisItem.Screen, ScreenTransition.Cover)

If your table of contents for the main screen comes from a data source, then you'll need to use some logic on the navigation to choose which screen to go (as I mentioned, you cannot navigate to a screen based on a value containing the screen name - you can consider creating a new item in the PowerApps Ideas board for this feature if you feel that it's important). For example, if the name of my screens came from a connected data source and only had the Title/Subtitle properties, I could have an OnSelect value like the one below:

If(
    Title = "Before DRI", Navigate(BeforeDRIScreen, ScreenTransition.Fade),
    Title = "During DRI", Navigate(DuringDRIScreen, ScreenTransition.Fade),
    Title = "After DRI", Navigate(AfterDRIScreen, ScreenTransition.Fade))
Anonymous
Not applicable

As far as I know, there is currently no way to refer to screen objects by a string containing their name. As previously suggested, you would have to create a table/collection containing references to the actual screen objects.

 

For example, you can have a gallery that displays a list of buttons.

But first, you should have a collection that contains screen references. You can set it up like this:

ClearCollect(ScreenReferences, Table(
    { Title: "Screen One", ScreenObject: ScreenOne },
    { Title: "Screen Two", ScreenObject: ScreenTwo },
    { Title: "Screen Three", ScreenObject: ScreenThree }
))

Add more records under the Table() function as needed. Then use that to populate the gallery.

 

Then, in your gallery, you can have a button object in the template.

The button object should have properties like these:

Text: ThisItem.Title
OnSelect: Navigate( ThisItem.ScreenObject, None )

Clicking a button on the gallery would navigate the user to the screen that is referenced.

 

There are a couple of things that are good to know about this method though.

  1. You can't pass context variables via this method. For some reason, you have to reference the screen object directly in order to pass a context variable. For example,
    Navigate( ScreenOne, None, { ContextVar: "Some Value" } )
  2. Since this is a gallery, the other buttons would be automatically generated. However, in Edit Mode, if you click on any button other than the first (the template button), the OnSelect would run and navigate you away from it.
Anonymous
Not applicable

Hi All,

 

Still not having any luck with this, I have this copied this from the OnSelect field from within my gallery. Error being given "This function Navigate has some invalid arguments".

 

ClearCollect(ScreenReferences, Table(
{ Title: "NHVAS Maintenance Minimum Checklist", ScreenObject: NHVASMaintenanceChecklist },
{ Title: "TruckSafe Minimum Checklist", ScreenObject: TrucksafeMinChecklist },
{ Title: "NHVAS and Trucksafe Minimum Checklist", ScreenObject: NHVASTrucksafeChecklist },
{ Title: "Mass Management Daily Vehicle Checklist", ScreenObject: MassManagementChecklist },
{ Title: "Vellex Daily Vehicle Checklist", ScreenObject: VellexDailyVehicleChecklist }
)) -
Navigate(ThisItem.ScreenObject, Fade )

Anonymous
Not applicable

I've also tried this in the Onselct field of the image within the Gallery I'm using as a button and still no luck. Error given "Invalid Argument Type"

 

 

If(
Title = "NHVAS Maintenance Minimum Checklist", Navigate(NHVASMaintenanceChecklist, ScreenTransition.Fade),
Title = "TruckSafe Minimum Checklist", Navigate(TrucksafeMinChecklist, ScreenTransition.Fade),
Title = "NHVAS and Trucksafe Minimum Checklist", Navigate(NHVASTrucksafeChecklist, ScreenTransition.Fade))


@Anonymous wrote:

I've also tried this in the Onselct field of the image within the Gallery I'm using as a button and still no luck. Error given "Invalid Argument Type"

 

 

If(
Title = "NHVAS Maintenance Minimum Checklist", Navigate(NHVASMaintenanceChecklist, ScreenTransition.Fade),
Title = "TruckSafe Minimum Checklist", Navigate(TrucksafeMinChecklist, ScreenTransition.Fade),
Title = "NHVAS and Trucksafe Minimum Checklist", Navigate(NHVASTrucksafeChecklist, ScreenTransition.Fade))


If you reduce the formula to its minimum:

If(Title = "NHVAS Maintenance Minimum Checklist", Navigate(NHVASMaintenanceChecklist, ScreenTransition.Fade))

Do you still see the error? If yes, then try to hover across the two parameters of the function, to see if the error has more information.

 

Do you not see the error? Then start adding the other options one at a time until you see an error; when you do, hover on the formula bar to see if you get more information about it.

Anonymous
Not applicable

Hi.

 

If you're going to use my way (CarlosFigueira's method is also valid), you should define the collection before the gallery. I usually do mine on the OnStart property of the first screen but that needs the app to be restarted if make edits in there (Because OnStart doesn't get executed in the F5 Preview). For now, you can do it in the OnVisible property of the screen your gallery is in.

 

ClearCollect(ScreenReferences, Table(
{ Title: "NHVAS Maintenance Minimum Checklist", ScreenObject: NHVASMaintenanceChecklist },
{ Title: "TruckSafe Minimum Checklist", ScreenObject: TrucksafeMinChecklist },
{ Title: "NHVAS and Trucksafe Minimum Checklist", ScreenObject: NHVASTrucksafeChecklist },
{ Title: "Mass Management Daily Vehicle Checklist", ScreenObject: MassManagementChecklist },
{ Title: "Vellex Daily Vehicle Checklist", ScreenObject: VellexDailyVehicleChecklist }
))

 

Then, in your gallery, do this for the Items property.

ScreenReferences

Then, create a button in the gallery template with the following properties:

Text: ThisItem.Title
OnSelect: Navigate(ScreenObject, ScreenTransition.None)

And another thing: Are the objects assigned for ScreenReferences.ScreenObjects screens? If they're not (because the names suggest they are radio objects), then that may be where the errors are coming from.

 

Let me know if that works.

Anonymous
Not applicable

Thanks Everyone,

 

If finally got it using the formula's below.

 

If(
Title5.Text = "NHVAS Maintenance Minimum Checklist", Navigate(NHVASMaintenanceChecklist, ScreenTransition.Fade),
Title5.Text = "TruckSafe Minimum Checklist", Navigate(TrucksafeMinChecklist, ScreenTransition.Fade),
Title5.Text = "NHVAS and Trucksafe Minimum Checklist", Navigate(NHVASTrucksafeChecklist, ScreenTransition.Fade))

@CarlosFigueira 
I have the same issue and didn't get it to work.

My goal is to navigate to different screens from my gallery using the arrows.

I've tried to set the onselect of my arrow in my gallery to the following:

If(Title2 = "ScrewConfig1"; Navigate(Screw_Configuration_1; ScreenTransition.Fade))

  

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,845)