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
Super User

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Users online (2,295)