cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
WorkHard
Helper III
Helper III

Parent/child list in a Power App: How to implement a button that adds a row and moves/resizes the form.

Let's say I have two lists:

-Projects

-Project Employees.

 

In the Projects list, I have the following columns: UID, Name, Project Number;

In the Project Employees I have the following columns: UID, Project_UID, Employee Name, Start Date, End Date.

 - UID - is the primary list unique ID.

- Project_UID is a look up field for the "Projects" list UID field. It's set up as an index with cascade delete.

 

Now, I'm trying to understand what would be the controls that would allow me to create an "Add" button that would continuously add a new "row/section" for me to type the new employee details (child) for this list. When clicking on the add button, the form/card should extend or create a new employee section to allow adding as many employee rows I would like.

 

Check out this video at 7:11 mark to understand what I mean: https://youtu.be/AdAGFR3UIW8?t=431

 

Can this be achieved with a gallery?

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @WorkHard ,

Do you want to add new records to your Project Employees list continuously through the "Add" button?

 

Based on the needs that you mentioned, I think the Gallery control could achieve your needs. Please check and see if the following video resources could help in your scenario:

https://www.youtube.com/watch?v=xgznk4XlPCo

https://www.youtube.com/watch?v=DylxsXIUyDc

https://www.youtube.com/watch?v=vjfrXUa1Juw

 

I have made a test on my side, please consider take a try with the following workaround:

1.JPG2.JPG3.JPG4.JPG5.JPG

Set the OnStart property of App to following:

ClearCollect(GalleryCollection, CountRows(GalleryCollection)+1)

Add a "+" icon in your screen, set the OnSelect property to following:

Collect(GalleryCollection, CountRows(GalleryCollection)+1)

Add a Gallery, set the Items property to following:

GalleryCollection

within the Gallery, add a Text Input, a ComboBox, two Date Pickers and a "Save" icon. And outside the Gallery, add several Labels above the Gallery to act as column headers.

 

Set the Items property of the Project_UID ComboBox within the Gallery to following:

Choices('Project Employees'.Project_UID)

set the SelectMultiple property of this ComboBox to false.

 

Set the OnSelect property of the "Save" Icon within the Gallery to following:

Patch(
      'Project Employees', 
       Defaults('Project Employees'),
      {
        Title: "Entry Record",
        'Employee Name': EmployeeNameTex.Text,
        Project_UID: ProjectUIDComboBox.Selected,
        'Start Date': StartDatePicker.SelectedDate,
        'End Date': EndDatePicker.SelectedDate
      }
)

 

Set the OnSelect property of the "Patch All" button to following:

ForAll(
       Gallery1.AllItems, 
       Patch(
            'Project Employees', 
            Defaults('Project Employees'),
           {
             Title: "Entry Record",
             'Employee Name': EmployeeNameTex.Text,
             Project_UID: ProjectUIDComboBox.Selected,
             'Start Date': StartDatePicker.SelectedDate,
             'End Date': EndDatePicker.SelectedDate
           }
)
)

Please take a try with above solution, check if the issue is solved.

 

Patch function, ForAll function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xida-msft
Community Support
Community Support

Hi @WorkHard ,

Do you want to add new records to your Project Employees list continuously through the "Add" button?

 

Based on the needs that you mentioned, I think the Gallery control could achieve your needs. Please check and see if the following video resources could help in your scenario:

https://www.youtube.com/watch?v=xgznk4XlPCo

https://www.youtube.com/watch?v=DylxsXIUyDc

https://www.youtube.com/watch?v=vjfrXUa1Juw

 

I have made a test on my side, please consider take a try with the following workaround:

1.JPG2.JPG3.JPG4.JPG5.JPG

Set the OnStart property of App to following:

ClearCollect(GalleryCollection, CountRows(GalleryCollection)+1)

Add a "+" icon in your screen, set the OnSelect property to following:

Collect(GalleryCollection, CountRows(GalleryCollection)+1)

Add a Gallery, set the Items property to following:

GalleryCollection

within the Gallery, add a Text Input, a ComboBox, two Date Pickers and a "Save" icon. And outside the Gallery, add several Labels above the Gallery to act as column headers.

 

Set the Items property of the Project_UID ComboBox within the Gallery to following:

Choices('Project Employees'.Project_UID)

set the SelectMultiple property of this ComboBox to false.

 

Set the OnSelect property of the "Save" Icon within the Gallery to following:

Patch(
      'Project Employees', 
       Defaults('Project Employees'),
      {
        Title: "Entry Record",
        'Employee Name': EmployeeNameTex.Text,
        Project_UID: ProjectUIDComboBox.Selected,
        'Start Date': StartDatePicker.SelectedDate,
        'End Date': EndDatePicker.SelectedDate
      }
)

 

Set the OnSelect property of the "Patch All" button to following:

ForAll(
       Gallery1.AllItems, 
       Patch(
            'Project Employees', 
            Defaults('Project Employees'),
           {
             Title: "Entry Record",
             'Employee Name': EmployeeNameTex.Text,
             Project_UID: ProjectUIDComboBox.Selected,
             'Start Date': StartDatePicker.SelectedDate,
             'End Date': EndDatePicker.SelectedDate
           }
)
)

Please take a try with above solution, check if the issue is solved.

 

Patch function, ForAll function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Thank you for this very detailed response!

 

I just have one more thing that I need to wrap my head around:

For the master list (Project List), I still want to browse directly in Sharepoint. I'm using the Power app only as the view, edit form. Just like in the old sharepoint were the form is the infopath but the viewing aspect is just a sharepoint list.

 

Now, how do I make the default sharepoint "double click on an item" action to ope the record in power apps form with a collection ready,etc.? Or the "New" button in the sharepoint list?

I can't just add this to the screen OnLoad funtion because the logic is different depending on if the record is new or in edit mode.

 

It sounds like this solution would only work if you go Full Power Apps and don't use the SharePoint interface at all.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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.

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