cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
n1ckmuk
Helper I
Helper I

Patch a collection to SQL

I have an app that loads data from a SQL table into a collection. 
The app then lets you modify data in the collection as well as add new rows. 

 

I would like to patch the collection back to SQL, overwriting the existing data and adding the new rows where appropriate. 

Is this possible?

5 REPLIES 5
WarrenBelz
Super User III
Super User III

Hi @n1ckmuk ,

Yes - it would be better to separate the new records as different syntax would be require. You could have a simple flag on these.

Happy to help with syntax if you get stuck.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Thanks! 

That makes sense..

So save new records in a completely separate collection? 

 

Then on onselect run two patch commands?

Hi @n1ckmuk ,

Yes, that would work as well - probably better and simpler.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Thanks, I've made quite a bit of progress, but seem to be struggling with patching an existing SQL record. Creating a record works fine with 'Defaults'.
I've made a separate app to test this on its own;
the Collection updates successfully, but the SQL table does not. No errors. 

 

 

I create a copy of my SQL table in a collection 

 

 

ClearCollect(PowerAppsCollection,
            '[Analysis].[PowerAppsInputTest]'
)

 

 

 

Capture.PNG

the datatables at the bottom show the relevant table filtered by the ID text box.

 

 

First(Filter('[Analysis].[PowerAppsInputTest]',PowerAppsInputTestID in TextInput1.Text))
First(Filter(PowerAppsCollection,PowerAppsInputTestID in TextInput1.Text))

 

 


Patch SQL And Patch collection buttons are;

 

 

Patch(
    '[Analysis].[PowerAppsInputTest]',
    First(
        Filter(
            '[Analysis].[PowerAppsInputTest]',
            PowerAppsInputTestID = TextInput1.Text
        )
    ),
    {DemeritScore: Value(TextInput2.Text)
        )}
);
Patch(
    PowerAppsCollection,
    First(
        Filter(
            DataWarehouse,
            PowerAppsInputTestID in TextInput1.Text
        )
    ),
    {DemeritScore: Value(TextInput2.Text)}
)

 

 


Any ideas?

Thanks, I've made quite a bit of progress, but seem to be struggling with patching an existing SQL record. Creating a record works fine with 'Defaults'.
I've made a separate app to test this on its own;
the Collection updates successfully, but the SQL table does not. No errors. 

 

 

I create a copy of my SQL table in a collection 

 

 

 

 

ClearCollect(PowerAppsCollection,
            '[Analysis].[PowerAppsInputTest]'
)

 

 

 

 

 

Capture.PNG

the datatables at the bottom show the relevant table filtered by the ID text box.

 

 

 

 

First(Filter('[Analysis].[PowerAppsInputTest]',PowerAppsInputTestID in TextInput1.Text))
First(Filter(PowerAppsCollection,PowerAppsInputTestID in TextInput1.Text))

 

 

 

 


Patch SQL And Patch collection buttons are;

 

 

 

 

Patch(
    '[Analysis].[PowerAppsInputTest]',
    First(
        Filter(
            '[Analysis].[PowerAppsInputTest]',
            PowerAppsInputTestID = TextInput1.Text
        )
    ),
    {DemeritScore: Value(TextInput2.Text)
        )}
);
Patch(
    PowerAppsCollection,
    First(
        Filter(
            DataWarehouse,
            PowerAppsInputTestID in TextInput1.Text
        )
    ),
    {DemeritScore: Value(TextInput2.Text)}
)

 

 

 

 


Any ideas?

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,546)