web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Apps
Answered

Repeating Tables

(0) ShareShare
ReportReport
Posted on by 184

Hi:

Watched some videos on this and have it sort of working, but when clicking the save button to add a new row it duplicates and puts up two rows:

Here is the code that creates the collection which is on the initial screen:

NewForm(Form1);
Set(varNewReq, true);
ClearCollect(colRequisition, {RegistrationNumber: "", Quantity: 1, ItemNumber: "", ItemSize: "", Description: "", Area: "", Department: "", AccountDescription: "", AccountNumber: "", Allocation: 1, EachPrice: 0, TotalPrice: 0  } );  
Navigate(NewRequisition, ScreenTransition.Cover);
 
When the detail screen loads and the data is populated the following code DOES leave the initial row in place and DOES create a new row but also duplicates the current row:
Code: on the detail screen:
Collect(colRequisition,ThisItem, {Quantity: Value(txtquantity.Text), ItemNumber: txtitemnumber.Text, ItemSize: drpitemsize.Selected.Value, Description: txtdescription.Text, Area: drparea.Selected.Area, Department: drpdept.Selected.DEPARTMENT, AccountDescription: drpacctdescr.Selected.Section, AccountNumber: txtacctnumber.Text, EachPrice: Value(txteachprice.Text), TotalPrice: Value(txttotalprice.Text)});

 Screen shot of affected area:
chtraywick_0-1704547414471.png

Appreciate any thoughts that some might have.

best Regards

Chuck

Categories:
  • WarrenBelz Profile Picture
    156,963 Most Valuable Professional on at

    Hi @chtraywick ,

    Try using Patch instead of Collect on the second code.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • chtraywick Profile Picture
    184 on at

    Thank you Warren for your help, much appreciated.  If we replace the Collect with Patch, the Patch DOES write out the correct record, but the existing row gets mostly blanked and we do not get another row for the user to enter data into.  Patch wrote the record correctly:

    chtraywick_0-1704614295330.png

    But the row on the screen gets partially erased and no second row for data entry:

    chtraywick_1-1704614362345.png

    Patch code:

    Patch(colRequisition, ThisItem, {Quantity: Value(txtquantity.Text), ItemNumber: txtitemnumber.Text, ItemSize: drpitemsize.Selected.Value,  Description: txtdescription.Text, Area: drparea.Selected.Area, Department: drpdept.Selected.DEPARTMENT, AccountSection:drpacctdescr.Selected.Section, AccountNumber: txtacctnumber.Text, EachPrice: Value(txteachprice.Text), TotalPrice: Value(txttotalprice.Text)});
     
    if we leave Patch in place AND do collect we get:
    chtraywick_2-1704614532900.png

     

    If we just use COLLECT we get the following which is the closest the first row retains the data properly, the second row is a new data entry row which is correct but getting an extra third row which is repeating the current row.  This is closer except for that third row.

    chtraywick_3-1704614930254.png

    Aay thoughts ?

    Thank you

    Chuck

     

     

     


     

     

  • chtraywick Profile Picture
    184 on at

    Tried this and this now seems to work:

    Collect(colRequisition,ThisItem, {Quantity: Value(txtquantity.Text), ItemNumber: txtitemnumber.Text, ItemSize: drpitemsize.Selected.Value, Description: txtdescription.Text, Area: drparea.Selected.Area, Department: drpdept.Selected.DEPARTMENT, AccountDescription: drpacctdescr.Selected.Section, AccountNumber: txtacctnumber.Text, EachPrice: Value(txteachprice.Text), TotalPrice: Value(txttotalprice.Text)});

    Remove(colRequisition, LastN(colRequisition,1))
    Rows:
    chtraywick_4-1704615956566.png

     

  • CU18061035-1 Profile Picture
    Microsoft Employee on at

    hey @chtraywick 

     

    try this one:

    // Code on the detail screen:
    Collect(
     colRequisition,
     {
     Quantity: Value(txtquantity.Text),
     ItemNumber: txtitemnumber.Text,
     ItemSize: drpitemsize.Selected.Value,
     Description: txtdescription.Text,
     Area: drparea.Selected.Area,
     Department: drpdept.Selected.DEPARTMENT,
     AccountDescription: drpacctdescr.Selected.Section,
     AccountNumber: txtacctnumber.Text,
     EachPrice: Value(txteachprice.Text),
     TotalPrice: Value(txttotalprice.Text)
     }
    );

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • chtraywick Profile Picture
    184 on at

    Thank you, will test it and get back to you in a bit

  • Verified answer
    WarrenBelz Profile Picture
    156,963 Most Valuable Professional on at

    Hi @chtraywick ,

    You simply need to add Collect on the end of the Patch to create another new record if that is what you want to do. I am not sure what you mean about the existing record being blanked as it should write whatever you have in the first code below to the current record assuming here you are running the code from inside the gallery on the relevant record.

    Patch(
     colRequisition,
     ThisItem, 
     {
     Quantity: Value(txtquantity.Text), 
     ItemNumber: txtitemnumber.Text, 
     ItemSize: drpitemsize.Selected.Value, 
     Description: txtdescription.Text, 
     Area: drparea.Selected.Area, 
     Department: drpdept.Selected.DEPARTMENT, 
     AccountDescription: drpacctdescr.Selected.Section, 
     AccountNumber: txtacctnumber.Text, 
     EachPrice: Value(txteachprice.Text), 
     TotalPrice: Value(txttotalprice.Text)
     }
    );
    Collect(
     colRequisition, 
     {
     RegistrationNumber: "", 
     Quantity: 1, ItemNumber: "", 
     ItemSize: "", 
     Description: "", 
     Area: "", 
     Department: "", 
     AccountDescription: "", 
     AccountNumber: "", 
     Allocation: 1, 
     EachPrice: 0, 
     TotalPrice: 0 
     } 
    ); 

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • chtraywick Profile Picture
    184 on at

    Thank you Warren, will test this in a few.  The current row when we execute patch resets the drop downs to their initial state.  So if we picked say Corporate from the first drop down then the next two drop downs get prepopulated with defaults based on what is selected in the first drop down, the user can then change those next two if they like.  When we click the save button using PATCH all of the three drop downs get reset to their initial state.  SO if a user is populating several rows at a time they will want to see what they did in the previous row.

  • Verified answer
    WarrenBelz Profile Picture
    156,963 Most Valuable Professional on at

    Hi @chtraywick ,

    This is an issue with the Default value of the controls, not the Patch. Depending whether they are Drop-down or Combo Box controls, you set the Default or DefaultSelectedItems. As you are writing back to Text fields, this gets a bit easier so for Combo Boxes the DefaultSelectedItems would be ItemSize

    {Value: ThisItem.ItemSize}

    Department

    {DEPARTMENT: ThisItem.Department}

    AccountDescription

    {Section: ThisItem.AccountDescription}

    If they are Drop-downs, you only need the field name in the Default - example

    ThisItem.ItemSize

    Also all of your Text control Default values need to be set to the relevant field name as above.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • chtraywick Profile Picture
    184 on at

    Thank you, testing it now

  • chtraywick Profile Picture
    184 on at

    Should these be set when the collection is setup, on in the properties of each item that we can see by clicking on a field, say drparea in the advanced section or in the collect?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 221 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 120

Last 30 days Overall leaderboard