cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tofsweden
Helper II
Helper II

How to link 2 galleries to one detail screen

I've one gallery 'BrowseGallery2' where you can browse and filter all employees, and then click on button to get to their individual details in 'detailscreen1'.

Also I got another gallery 'Gallery1' in another screen where every employee belonging to one department shows up (based on predefined values), there is also a button for each employee linking to 'detailscreen1'. And I want to link that gallery to the said same detail screen but it seems not possible?!

 

I've tried with following codes in detailscreen1

 

BrowseGallery2.Selected&Gallery1.Selected

and this 

BrowseGallery2.Selected||Gallery1.Selected

Neither works, do you know how to?

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
mr-dang
Community Champion
Community Champion

Hi, 

I can think of two ways of doing this.

  1. Use a condition around the Items property of the Display Form Viewer (on detailscreen1). Use a context variable to determine which situation the user is in.
  2. Upon clicking the button to Navigate, also Collect the record for viewing.

Both methods will only work if BrowseGallery1 and Gallery2 draw information from the same datasource--in other words, they must have identical columns or it won't work properly.

 

Method 1

The third argument for Navigate can transfer a context variable.

 

For the screen browsing/filtering all employees:
Navigate(detailscreen1,Fade,{variable: 1})

For the screen looking at a department of employees:
Navigate(detailscreen1,Fade,{variable: 2})

The variable created will determine what situation the user will be in. When the variable is 1, we will make the Display Form Viewer show the information selected in BrowseGallery2. When the variable is 2, we will make the Display Form Viewer show information selected in Gallery2.

 

 

Set the Items property of the Display Form Viewer to show the desired record:

 

If(variable=1,BrowseGallery2.Selected,
    variable=2,Gallery2.Selected
)

Sometimes that may not work depending on the configuration of your galleries. You may instead opt to use the unique identifier in your datasource to determine exactly which record you're referring to. In this case, RecordId refers to a field that uniquely identifies each row:

 

If(variable=1,First(Filter(datasource,RecordId=BrowseGallery2.Selected.RecordId)),
    variable=2,First(Filter(datasource,RecordId=Gallery2.Selected.RecordId))
)

So in method 1, the variable determines what record the user will be viewing.

 

In method 2, you can opt to Collect the exact record you want to avoid ambiguity and variables altogether.

 

Method 2

Program the Buttons you use for navigating to Collect the exact record you want.

ClearCollect(viewEmployee,ThisItem);
Navigate(detailscreen1,Fade)

The formula above should work, but if there is ambiguity, you can use this to be more specific:

ClearCollect(viewEmployee,First(Filter(datasource,RecordId=ThisItem.RecordId)));
Navigate(detailscreen1,Fade)

 

The same formula should work for buttons in both BrowseGallery1 and Gallery2 since ThisItem is relative to the stated gallery.

 

Now that you have collected a record you wish to show, you can configure the Items property of your Data Form Viewer to show the first record of the temporary collection you made:

First(viewEmployee)

Let me know how this works out for you.

Microsoft Employee
@8bitclassroom

View solution in original post

3 REPLIES 3
hpkeong
Community Champion
Community Champion

Hi

 

Looks like you are trying to do "Merging"?

In normal case, you can only CLICK on one gallery and navigate to another detail screen based on the "Selected" results.

So, I don;t it is possible to "Click: two gallery at one time.

What you are looking for might be:

- Filter based on two "Criteria", not two gallery selection.

 

Hope I am right.

TQ

hpkeong
mr-dang
Community Champion
Community Champion

Hi, 

I can think of two ways of doing this.

  1. Use a condition around the Items property of the Display Form Viewer (on detailscreen1). Use a context variable to determine which situation the user is in.
  2. Upon clicking the button to Navigate, also Collect the record for viewing.

Both methods will only work if BrowseGallery1 and Gallery2 draw information from the same datasource--in other words, they must have identical columns or it won't work properly.

 

Method 1

The third argument for Navigate can transfer a context variable.

 

For the screen browsing/filtering all employees:
Navigate(detailscreen1,Fade,{variable: 1})

For the screen looking at a department of employees:
Navigate(detailscreen1,Fade,{variable: 2})

The variable created will determine what situation the user will be in. When the variable is 1, we will make the Display Form Viewer show the information selected in BrowseGallery2. When the variable is 2, we will make the Display Form Viewer show information selected in Gallery2.

 

 

Set the Items property of the Display Form Viewer to show the desired record:

 

If(variable=1,BrowseGallery2.Selected,
    variable=2,Gallery2.Selected
)

Sometimes that may not work depending on the configuration of your galleries. You may instead opt to use the unique identifier in your datasource to determine exactly which record you're referring to. In this case, RecordId refers to a field that uniquely identifies each row:

 

If(variable=1,First(Filter(datasource,RecordId=BrowseGallery2.Selected.RecordId)),
    variable=2,First(Filter(datasource,RecordId=Gallery2.Selected.RecordId))
)

So in method 1, the variable determines what record the user will be viewing.

 

In method 2, you can opt to Collect the exact record you want to avoid ambiguity and variables altogether.

 

Method 2

Program the Buttons you use for navigating to Collect the exact record you want.

ClearCollect(viewEmployee,ThisItem);
Navigate(detailscreen1,Fade)

The formula above should work, but if there is ambiguity, you can use this to be more specific:

ClearCollect(viewEmployee,First(Filter(datasource,RecordId=ThisItem.RecordId)));
Navigate(detailscreen1,Fade)

 

The same formula should work for buttons in both BrowseGallery1 and Gallery2 since ThisItem is relative to the stated gallery.

 

Now that you have collected a record you wish to show, you can configure the Items property of your Data Form Viewer to show the first record of the temporary collection you made:

First(viewEmployee)

Let me know how this works out for you.

Microsoft Employee
@8bitclassroom

View solution in original post

Did the first method, worked like a charm. Thank you very much!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,234)