cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SKH19 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
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
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
SKH19 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
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Top Solution Authors
Top Kudoed Authors
Users online (5,918)