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 / Get Multiple ID's from...
Power Apps
Unanswered

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

(0) ShareShare
ReportReport
Posted on by 30

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.

Categories:
I have the same question (0)
  • russrimm Profile Picture
    Microsoft Employee on at

    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 Profile Picture
    30 on at

    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 Profile Picture
    Microsoft Employee on at

    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 Profile Picture
    30 on at

    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.

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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 316 Most Valuable Professional

#2
11manish Profile Picture

11manish 242

#3
Valantis Profile Picture

Valantis 198

Last 30 days Overall leaderboard