cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Impactful Individual
Impactful Individual

Connecting Items to Distinct Galleries

This might be a CDS database design issue, which I'm not very good at, but maybe someone can help me out.

Say I have a custom CDS entity called EmployeeTests. In my custom entity in CDS I have a list of employees and their statuses on 4 different tests. So for every employee there are 4 different records. Like this:

image.png

I need to display the employees by name in a gallery and then have a form where they can edit the 4 columns. But I can't have 4 different entries per employee. So I created a gallery and set the Items property to:

Distinct(EmployeeTests, Employee)

This worked to only show one record for each employee.

But now how do I link items to the gallery selection? If I create a form with Items property Gallery1.Selected, it returns an error because it doesn't know which of the 4 records for that employee to display. But what I want is for the form to show all of the common info from each of the records, like Job, and the statuses for each of the tests.

Functionally it would look something like this: (I just drew this up with labels)

image.png

Does this make sense? How could I go about designing something like this? My actual case is much more complicated, but the basic problem is displayed here.

Thanks for any help you can offer.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Connecting Items to Distinct Galleries

Hi @SKH19 ,

 

If you want use a Edit Form to display and edit employee details like your form shows , you can refer to the following steps.

1. Create a blank Edit Form, set Default mode as New and add two custom DataCard.

2. In DataCard1, add two Textinput boxes,  set Defaults property as below.

Textinput4: Gallery1.Selected.Result
Textinput5: LookUp(EmployeeTests, Employee=Gallery1.Selected.Result).Job

3. In DataCard2, Add a “Test” label set Text property as “Test”. Add four Textinput boxes, set Defaults Property as below.

Textinput6: Last(FirstN(Filter(EmployeeTests,Employee=Gallery1.Selected.Result),1)).Test
Textinput6_1: Last(FirstN(Filter(EmployeeTests,Employee=Gallery1.Selected.Result),2)).Test
Textinput6_2: Last(FirstN(Filter(EmployeeTests,Employee=Gallery1.Selected.Result),3)).Test
Textinput6_3: Last(FirstN(Filter(EmployeeTests,Employee=Gallery1.Selected.Result),4)).Test

4. Add a “Submit” button, set OnSelect property as below.

Concurrent(
Patch(EmployeeTests,Last(FirstN(Filter(EmployeeTests,Employee=Gallery1.Selected.Result),1)),{ employee:TextInput4.Text,Job:TextInput5.Text, test:TextInput6.Text}),
Patch(EmployeeTests,Last(FirstN(Filter(EmployeeTests,Employee=Gallery1.Selected.Result),2)),{ employee:TextInput4.Text,Job:TextInput5.Text, test:TextInput6_1.Text}),
Patch(EmployeeTests,Last(FirstN(Filter(EmployeeTests,Employee=Gallery1.Selected.Result),3)),{ employee:TextInput4.Text,Job:TextInput5.Text, test:TextInput6_2.Text}),
Patch(EmployeeTests,Last(FirstN(Filter(EmployeeTests,Employee=Gallery1.Selected.Result),4)),{ employee:TextInput4.Text,Job:TextInput5.Text, test:TextInput6_3.Text})
)

Annotation 2019-09-05 141338.png

Best regards,
Sik

View solution in original post

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: Connecting Items to Distinct Galleries

Hi @SKH19 ,

 

If you want use a Edit Form to display and edit employee details like your form shows , you can refer to the following steps.

1. Create a blank Edit Form, set Default mode as New and add two custom DataCard.

2. In DataCard1, add two Textinput boxes,  set Defaults property as below.

Textinput4: Gallery1.Selected.Result
Textinput5: LookUp(EmployeeTests, Employee=Gallery1.Selected.Result).Job

3. In DataCard2, Add a “Test” label set Text property as “Test”. Add four Textinput boxes, set Defaults Property as below.

Textinput6: Last(FirstN(Filter(EmployeeTests,Employee=Gallery1.Selected.Result),1)).Test
Textinput6_1: Last(FirstN(Filter(EmployeeTests,Employee=Gallery1.Selected.Result),2)).Test
Textinput6_2: Last(FirstN(Filter(EmployeeTests,Employee=Gallery1.Selected.Result),3)).Test
Textinput6_3: Last(FirstN(Filter(EmployeeTests,Employee=Gallery1.Selected.Result),4)).Test

4. Add a “Submit” button, set OnSelect property as below.

Concurrent(
Patch(EmployeeTests,Last(FirstN(Filter(EmployeeTests,Employee=Gallery1.Selected.Result),1)),{ employee:TextInput4.Text,Job:TextInput5.Text, test:TextInput6.Text}),
Patch(EmployeeTests,Last(FirstN(Filter(EmployeeTests,Employee=Gallery1.Selected.Result),2)),{ employee:TextInput4.Text,Job:TextInput5.Text, test:TextInput6_1.Text}),
Patch(EmployeeTests,Last(FirstN(Filter(EmployeeTests,Employee=Gallery1.Selected.Result),3)),{ employee:TextInput4.Text,Job:TextInput5.Text, test:TextInput6_2.Text}),
Patch(EmployeeTests,Last(FirstN(Filter(EmployeeTests,Employee=Gallery1.Selected.Result),4)),{ employee:TextInput4.Text,Job:TextInput5.Text, test:TextInput6_3.Text})
)

Annotation 2019-09-05 141338.png

Best regards,
Sik

View solution in original post

Highlighted
Impactful Individual
Impactful Individual

Re: Connecting Items to Distinct Galleries

Yes this mostly works thank you very much!

The only issue is that if I make a change in one employee and don't submit it, then switch to another employee, the change carries through. So I will have to play around with it somehow to make sure they can't change employees without either submitting or cancelling changes. 

I will need to watch some tutorials on Last and FirstN too, I want to know how the language is reading in your solution!

Thanks!

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (3,768)