cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
BrianHFASPS
Level 8

UpdateIF misses some changes maybe patch instead?

I have a button that resets a SQL table with this UpdateIF command:

UpdateIf('[dbo].[Pickup Tracking]', 'Car Order' <> 0, {'Car Order':0, 'Send Out Order':0, 'Load Order':0})

It doesn't work reliably. It is usually acting on about 60 rows. The Send Out Order gets updated on about 95% of rows but Car Order and Load Order are 100%. Maybe it is timing out or something? Takes about 30 seconds sometimes. I was thinking of trying Patch instead. I came up with this code:

Patch('[dbo].[Pickup Tracking]', Filter('[dbo].[Pickup Tracking]', 'Car Order' <> 0), {'Car Order':0, 'Send Out Order':0, 'Load Order':0})

It seems Patch can't except a table of records to update? In reading documentation it seems to indicate it can. Do I have syntax wrong?

3 REPLIES 3
Community Support Team
Community Support Team

Re: UpdateIF misses some changes maybe patch instead?

HI @BrianHFASPS,

I think that there is something wrong in your formula.

The second parameter of patch function should be a specified record.

if you want to bulk update records , you can use patch function with forall function .

 

I made a test.

11.PNG

 

Set the onselect property of the button to:

ForAll(AddColumns(Filter('[dbo].[Pickup Tracking]','Car Order'<>0),"ID1",ID),Patch('[dbo].[Pickup Tracking]',LookUp('[dbo].[Pickup Tracking]',ID=ID1),{'Car Order':0, 'Send Out Order':0, 'Load Order':0}))

regards,

eason

Community Support Team _ Eason YU
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BrianHFASPS
Level 8

Re: UpdateIF misses some changes maybe patch instead?

Thanks for your response but according to https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch "Use the Patch function to modify one or more records of a data source." My formula works about 95% it just doesn't replace some of the 

'Send Out Order'

values in all rows. It seems your code circumvents the reason that patch exists? Why run a loop on a command that can internally loop? 

Community Support Team
Community Support Team

Re: UpdateIF misses some changes maybe patch instead?

Hi @BrianHFASPS,

 

I made a test with UpdateIf function . There is no issue on my side .

It can update all  records  that meet the ctiteria .

 

Please try to clear your browser data .

If your SQL table is a large data set ,you can try to use a small data set and check if it is solved.

 

Regards,

Eason

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

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

Follow PowerApps on Twitter

Stay Up-to-Date by following PowerApps on Twitter

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 73 members 4,083 guests
Please welcome our newest community members: