cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MikeyMole
Advocate I
Advocate 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.

Anonymous
Not applicable

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 @Anonymous,

 

tried both (code for @Anonymous 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);
);

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,487)