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 / Posting Collections to...
Power Apps
Unanswered

Posting Collections to On-Premise SQL - Replicating data

(0) ShareShare
ReportReport
Posted on by 1

Hey, Not having an issue posting from the App to SQL, the issue is that if i have 3 items in the collection it's pasting 3 items in SQL table, but all as the last entry in the Collection. The Collection is grabbing all the data from a Gallery and apending it correct in the app, but when submitted its just the wrong data.

 

This is the code from the Gallery + add new:

Patch(
 SampleCollection,
 ThisItem,
 {
 SampleQtyCol: Value(Qty.Text),
 SampleQtyDescCol: QtyDesc.Text,
 SampleDateCol: Date.SelectedDate,
 SampleTypeCol: Type.Text,
 SampleTestCol: Test.Text,
 SampleReceivedCol: Received.Value
 }
);
Collect(
 SampleCollection,
 {
 SampleQtyCol: 0,
 SampleQtyDescCol: "",
 SampleDateCol: Today(),
 SampleTypeCol: "",
 SampleTestCol: "",
 SampleReceivedCol: false
 }
)

This is the code from OnSuccess.

ForAll(
 SampleCollection,
 If(
 !IsBlank(Qty),
 Patch(
 '[dbo].[SampleData]',
 Defaults('[dbo].[SampleData]'),
 {
 SampleDate: Date.SelectedDate,
 SampleQty: Value(Qty.Text),
 SampleQtyDesc: QtyDesc.Text,
 SampleType: Type.Text,
 SampleTest: Test.Text,
 SampleRecevied: Received.Value,
 SSFMaster: Form2.LastSubmit.SSFID
 }
 )
 )
)

I have attached the SQL Screenshoot.

Any help would be appreciated

SQLData Issue.PNG
Categories:
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    adding in @GregLi to help with this question

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Cranny In looking at the code, it appears it is the order of operations that are causing the problem. First you create the collection, then you clear it before you submit it. 

    Could you try editing the code so that the collection is cleared after the data has been submitted to SQL? Please let us know if this helps?

    PS. You reference form 2 in your code to submit to SQL, where is form 2 in this scenerio? 

    Thank you for your patience @Anonymous

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 224 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 126

Last 30 days Overall leaderboard