cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bmarshall
Level: Powered On

patch forall gallery control

I have a screen that has a dropdown of states and when a state is selected a gallery is filtered to the selected state.  I need to update an Azure SQL Server database table with the toggle (on/off or 1/0) for each record in the gallery.  Right now it is updating the wrong record, always the one above the one that is changed. The code on the submit button is this: 

 

ForAll(Gallery3.AllItems, Patch([dbo].[DisasterAreas], [dbo].[DisasterAreas], {countyselected: tglcountyselected.Value}))

 

DisasterAreas is the table to be updated and countyselected is the boolean field that I want to update.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: patch forall gallery control

Hi @bmarshall,

 

The patch function here:

Patch('[dbo].[DisasterAreas]', [dbo].[DisasterAreas], {countyselected: tglcountyselected.Value})

should have some problems finding the proper record.

Basically, the second part is the record you are trying to update with, but here you are using the whole table (not a record) as the parameter, I don't think that would work. 

 

For the Update that you would like to achieve, could you please share more details about that?

If the toggle is out the gallery control, and once button pressed, it will update all the filtered records in Gallery with the value of toggle into SQL Table, then I think the formula could be written in the following way:

Clearcollect(NewData, Gallery.Allitems);
Forall(renamecolumns(NewData, "Id","NewId"),
       patch('[dbo].[DisasterAreas]',first(filter('[dbo].[DisasterAreas]',Id=MewId)),{countyselected:tgcounty.Selected.Value})
           )

If I have any misunderstandings, please post back.

Regards,

Michael

Community Support Team _ Michael Shao
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

3 REPLIES 3
Community Support Team
Community Support Team

Re: patch forall gallery control

Hi @bmarshall,

 

The patch function here:

Patch('[dbo].[DisasterAreas]', [dbo].[DisasterAreas], {countyselected: tglcountyselected.Value})

should have some problems finding the proper record.

Basically, the second part is the record you are trying to update with, but here you are using the whole table (not a record) as the parameter, I don't think that would work. 

 

For the Update that you would like to achieve, could you please share more details about that?

If the toggle is out the gallery control, and once button pressed, it will update all the filtered records in Gallery with the value of toggle into SQL Table, then I think the formula could be written in the following way:

Clearcollect(NewData, Gallery.Allitems);
Forall(renamecolumns(NewData, "Id","NewId"),
       patch('[dbo].[DisasterAreas]',first(filter('[dbo].[DisasterAreas]',Id=MewId)),{countyselected:tgcounty.Selected.Value})
           )

If I have any misunderstandings, please post back.

Regards,

Michael

Community Support Team _ Michael Shao
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

bmarshall
Level: Powered On

Re: patch forall gallery control

This worked.  Thanks for the help v-micsh=msft.  Here is the final code that was used:

 

ClearCollect(NewData, Gallery3.AllItems);
ForAll(RenameColumns(NewData, "DisasterAreasId","NewId"),
Patch('[dbo].[DisasterAreas]',First(Filter('[dbo].[DisasterAreas]',DisasterAreasId=NewId)),{countyselected:tglcountyselected.Value}))

Community Support Team
Community Support Team

Re: patch forall gallery control

Hi @bmarshall,

Thanks for the update.

Beisdes, if it is convenient, please accept it as the solution to this question, which would help the others when may have the same problem to find the workable way easier.

 

Regards,

Michael

 

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

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: 207 members 6,414 guests
Please welcome our newest community members: