cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Update gallery to sql

Hello,

I have been trying to update all the data of a gallery. I'm using a SQL server to store all the data. 

The gallery is in this format:

image.png

I tried to update using the functions Update and UpdateIf, but I did not get the result I was expected.

Using UpdateIf  (condition: true -affecting all the table) all the records was updated to the last record.

Using Update I get a error id is needed, but when I add the ID another error shows saying id is generated by the server... (id is a PK from the table and is auto incremental)

Do you know how can I do to uptade the table?

Thank you for your time.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Update gallery to sql

HI @Anonymous ,

Do you want to update all data within your Gallery into your SQL Table via pressing a "Submit" button?

 

Based on the needs that you mentioned, I think the Update() function and UpdateIf() function both could not achieve your needs.

I think the combination of ForAll function and Patch function could achieve your needs. I have made a test on my side, please take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following formula:

 

ForAll(
          RenameColumns(Gallery1.AllItems, "id", "id1"),  /* <-- id represents the primary key column in your SQL Table */
          Patch(
                    '[dbo].[YourSQLTable]',
                     LookUp('[dbo].[YourSQLTable]', id = id1),
                    {
                         Nombre: TextInput1.Text,
                         Tipo: Dropdown1.Selected.Value,
                         Capacidad: TextInput2.Text,
                         Rendimiento: TextInput3.Text,
                         CapacidadM3: TextInput4.Text,
                         Armador: TextInput5.Text
                    }
          )
)

Note: The TextInput1, Dropdown1, TextInput2, ... represents the corresponding controls within your Gallery.

 

 

More details about the ForAll function and Patch function in PowerApps, please check the following article:

ForAll function

Patch function

 

The user @Helen_BB has faced same issue with you, please also check the response within the following thread:

https://powerusers.microsoft.com/t5/General-Discussion/Editing-multiple-records-in-a-gallery-help/m-p/152467

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Community Support Team
Community Support Team

Re: Update gallery to sql

HI @Anonymous ,

Do you want to update all data within your Gallery into your SQL Table via pressing a "Submit" button?

 

Based on the needs that you mentioned, I think the Update() function and UpdateIf() function both could not achieve your needs.

I think the combination of ForAll function and Patch function could achieve your needs. I have made a test on my side, please take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following formula:

 

ForAll(
          RenameColumns(Gallery1.AllItems, "id", "id1"),  /* <-- id represents the primary key column in your SQL Table */
          Patch(
                    '[dbo].[YourSQLTable]',
                     LookUp('[dbo].[YourSQLTable]', id = id1),
                    {
                         Nombre: TextInput1.Text,
                         Tipo: Dropdown1.Selected.Value,
                         Capacidad: TextInput2.Text,
                         Rendimiento: TextInput3.Text,
                         CapacidadM3: TextInput4.Text,
                         Armador: TextInput5.Text
                    }
          )
)

Note: The TextInput1, Dropdown1, TextInput2, ... represents the corresponding controls within your Gallery.

 

 

More details about the ForAll function and Patch function in PowerApps, please check the following article:

ForAll function

Patch function

 

The user @Helen_BB has faced same issue with you, please also check the response within the following thread:

https://powerusers.microsoft.com/t5/General-Discussion/Editing-multiple-records-in-a-gallery-help/m-p/152467

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

Re: Update gallery to sql

Hi, @v-xida-msft 

It works!!

Thank you

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: 106 members 5,268 guests
Please welcome our newest community members: