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 Platform Community / Forums / Power Apps / Patch multiple rows wi...
Power Apps
Unanswered

Patch multiple rows with number of inserted rows based on value

(0) ShareShare
ReportReport
Posted on by 30

I have a form that a user enters a certain number of boxes. This row has an ID with few other columns but the ID is all that really matters in this Table 1 for my issue. I have Table 2 that I need to copy over that ID number from Table 1 and insert the number of boxes entered as that many rows into Table 2. For example, in Table 1, ID=001 and I enter number of boxes as 10. I am done with Table 1 so I submit that form but I want the app to edit Table 2 to insert 10 more rows with the ID=001 and a number of boxes column to increment from 01 to 10, all of which keep ID=001. Thus Table 2 should then have 10 more rows with all rows of ID=001 and Box=01,02...09,10. 

The following is NOT correct, but am I on the right track?

ClearCollect(colBoxDatabaseInsert, {ID: DataCardValueID, QtyBox: DataCardValueQTY});
ForAll(colBoxDatabaseInsert,
Patch(BoxDatabase, First(Filter(BoxDatabase, FFID=DataCardValueID.Text)),{Box: 01})
);
SubmitForm(EditQCForm1);

back();

 

Eventually, I will be moving, at least, Table 2 to MySQL or SQL. I have an authentication issue with the MySQL server/gateway connection and will circle back to that later. Want to mention this in case this is easier to do or only to be done in SQL.

Categories:
I have the same question (0)
  • ryanmcc Profile Picture
    30 on at

    It looks like I should be using FirstN and letting the value be my qty enty so similar to FirstN(BoxDatabase, value(DataCardValueQTY)). I'm still not sure how the patch or filter works or if I need the ForAll()? 

  • ryanmcc Profile Picture
    30 on at

    Just an update here, I am able to simulate a WHILE function using the concept from this video. I can change the setup to use the Box value and count down to 0 instead of the counter being less than or equal to the Text input BUT it is in it's own infinite loop counting down from the Box value to 0 then starting over. I'm not sure what I can change on my setup below to get this count down to stop at 0.

    (For this testing purpose, I have my box qty setup as the txt_NumberBoxLoop text input box)

    Loop button OnSelect = If(varBoxCounter>=0,Set(varBoxLoop, true));
    Set(varBoxLoop, false);

    Toggle OnCheck = Set(varBoxCounter, If(varBoxCounter=0,Value(txt_NumberBoxLoop.Text),varBoxCounter-1));
    Select(btn_countsetup);

     

    I'm so close. Once I get this while statement setup, I can add a patch on the toggle button. 

  • ryanmcc Profile Picture
    30 on at

    OK, I was able to get this to work! Instead of counting down to zero, I left the toggle as counting up to the box qty and had the loop button changed to counter variable being < txt box instead of <=. This would enter the correct amount of boxes into Table2 with correct indexing box numbers. BUT, I can't get the ID to carry over for each index. It is only bringing over the indexed box number. Here is my patch;

     

    Patch(BoxDatabase, {ID: varIDQC}, {Box: varBoxCounter});

     

    The ID doesn't exist it the table so it creates a new row but it doesn't enter the ID into the ID's cell. Thoughts?

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 396 Most Valuable Professional

#2
11manish Profile Picture

11manish 134 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 101 Super User 2026 Season 2

Last 30 days Overall leaderboard