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

Patch within ForAll not working

Can someone please help me - this code was working fine only a few weeks ago!

//now save new orders
ForAll(col_current_tagprops,

//update the record with current disp_order
Patch('[dbo].[case_subtype_defprop]', LookUp('[dbo].[case_subtype_defprop]', case_subtype_defprop_pk = col_current_tagprops[@case_subtype_defprop_pk]), {disp_order:col_current_tagprops[@disp_order]});
);

1 ACCEPTED SOLUTION

Accepted Solutions

Update:

Code below works, I just created a stored procedure to do the UPDATE and called that from Flow which is referenced below. Works fine. Weird.

//now save new orders
ForAll(col_current_tagprops As tagprops,
        PowerAppsbutton_2.Run(tagprops.case_subtype_defprop_pk, tagprops.disp_order);
);

View solution in original post

6 REPLIES 6
JR-BejeweledOne
Super User
Super User

How is it not working?  Is it not creating a new record, or are you getting some error?   A couple initial thoughts, is it possible something in your data source has changed?   Have you tried refreshing the datasource?

 

Other than these initial things to look at, I can't help you further but any additional details you can provide will help the next person who looks at your question.

 

Good Luck



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

It's silently not updating the record(s). I know it should be working because if I collect a field value from the ForAll collection into a new collection it fills nicely with the values I'd expect to see.

It's like the patch is just silently failing. I've tried deleting and re-adding datasource, using Refresh() function, and when I take the patch outside of the forall and give it absolute values it works fine.

For now i'll have to find a workaround I guess.

I'm also not sure why it is happening, or not happening to update. But as a guess try to use "As" it is described in this blog https://powerapps.microsoft.com/el-gr/blog/formulas-thisrecord-as-and-sequence/   

Try this.   At the end of your patch statement add:

 

Collect(SubmitErrors, Errors(col_current_tagprops))

 

Then on another screen, add a data table and the data source is SubmitErrors.    Choose all the fields, you may get a red warning on the record field but it doesn't cause any issues.

 

I found this functionality recently and it has helped me as it captures submit error you might not otherwise see.

 

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

Many thanks @JR-BejeweledOne and @PeterWiensSPC,

 

tried both (code for @PeterWiensSPC fix below in case i'm doing it wrong), but again no update occuring in the database 😞

Can't see any errors - but thanks for the tips! good to know on both counts.

//now save new orders
ForAll(col_current_tagprops As tagprops,

//update the record with current disp_order
Patch('[dbo].[case_subtype_defprop]', LookUp('[dbo].[case_subtype_defprop]', case_subtype_defprop_pk = tagprops.case_subtype_defprop_pk), {disp_order:tagprops.disp_order});
);

Collect(SubmitErrors, Errors(col_current_tagprops))

Update:

Code below works, I just created a stored procedure to do the UPDATE and called that from Flow which is referenced below. Works fine. Weird.

//now save new orders
ForAll(col_current_tagprops As tagprops,
        PowerAppsbutton_2.Run(tagprops.case_subtype_defprop_pk, tagprops.disp_order);
);

View solution in original post

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!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,781)