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

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
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
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
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (68,348)