Announcements
Hello,
I'm building an app where I'm storing user inputs into a collection called UserCollection. Then, onButtonClick, Patching it to a sql server data source called (dbo.ItemsTable). It has auto increment number column (ItemId) while inserting rows into it. On Another Button click, I need to grab the rows from the dbo.ItemsTable and insert the rows in another sql table called dbo.AllItems. How do I insert multiple rows from one table to another? I can only do one row at a time. Is there a formula in PowerApps? Thanks in Advance. Hope I explained properly.
Check out the ForAll function, it sounds like what you're looking for. You can do a ForAll along with a Patch or Collect to accomplish this.
I tried the ForAll function but didn't had luck. It only writes one row into the second table and errors out with "Item created already on server". How do I insert multiple rows? Appreciate your input on this.
For the first one have you tried something like
ForAll(UserCollection.AllItems,Patch('ItemsTable',{ItemId:value(itemid.text),user:username.text})) (assuming the sql column is ItemId and the value in the app is Itemid.text, just as an example)
For the second one you could have it collect or clearcollect(items,'ItemsTable') and then ForAll(items.Allitems,Patch('AllItems',{col1:blah.text,col2:blah.text}))
I'm able to insert the items collected in "UserCollection" and Patch the items into table1 of sql server (Which generates id 215, id 216 in ItemID Column). How can I retrieve only the id of the two values from table 1(ItemId column name) and Patch the items in table2? ForAll is bringing the whole table1 id values. I Hope it was clear. Thanks for your help.
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.
Congratulations to our community stars!
Expanding mentorship, skilling, and AI innovation
These are the community rock stars!
Stay up to date on forum activity by subscribing.
WarrenBelz 316 Most Valuable Professional
11manish 242
Valantis 198