cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Kitz
Level: Powered On

Get Multiple ID's from one data source and patch into another data source

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.

4 REPLIES 4
russrimm
Level: Powered On

Re: Get Multiple ID's from one data source and patch into another data source

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.

Kitz
Level: Powered On

Re: Get Multiple ID's from one data source and patch into another data source

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.

russrimm
Level: Powered On

Re: Get Multiple ID's from one data source and patch into another data source

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}))

Kitz
Level: Powered On

Re: Get Multiple ID's from one data source and patch into another data source

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. 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 173 members 5,618 guests
Please welcome our newest community members: