cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RandyHayes
Super User
Super User

ThisRecord in a ForAll - Strange results

Greetings all.  You usually see me answering, but I thought I would post a question as I just ran into a bizarre situation with the (beloved) ThisRecord operator.

 

Cut to the chase, This formula (don't worry about the datasource, the limiting conditions, or data):

 

 

ForAll(
    Filter(Gallery1.AllItems, somelimitingcondition),

    UpdateIf(datasource, ID=ThisRecord.ID, {someData})
)

 

 

Will end up updating ALL of the records in the datasource.  If there are 2 out of 100 records returned by the Filter, all 100 records will be updated.  Definitely not expected!!

 

Interestingly enough, this formula:

 

ForAll(
    Filter(Gallery1.AllItems, somelimitingcondition),

    Collect(someCol, ThisRecord.ID);
    UpdateIf(datasource, ID=ThisRecord.ID, {someData})
)

 

 

Will STILL update all 100 records, but the collection will have 2 ID's in it!!!!

 

Have I been burned by a new function, or have I been working too hard?

 

I thought I would throw it out here to the collective to see if anyone else has experienced it.  I can reproduce it over and over.

 

And by the way - thank you to my friend @Gorilla_8 for taking me through a long journey to discover this (especially since I've been using the first formula a lot lately after waiting for ThisRecord for so long.)

 

Also by the way...I know the solution to resolve the problem as far as not using the ThisRecord operator, but that is not the point here.  Looking for anyone else experiencing this before reporting as a Bug!

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
3 REPLIES 3
WarrenBelz
Super User
Super User

Thanks @RandyHayes ,

Saved me some grief as this was the next on my list to start exploring and as you have noted, it could produce some nasty results if used on live data.

I will stick to the As statement now as this works great on the Ambiguity issues in a ForAll with the same fields.

Definitely a bug that needs reporting to MS - and soon.

 

@WarrenBelz 

Yes, I thought I would throw it out here on the forum to see if anyone has experienced this and also to serve as a warning for those contemplating using it.

 

I put together a demo of this using a collection (still same result).  

The more I reviewed this and put the demo together the more I started to realize that perhaps this is not so much a bug in ThisRecord and ForAll, but more of an oversight in the documentation!

 

See the attached app for more details.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Guillaume_G
Helper I
Helper I

Hi @RandyHayes ,

 

Did you ever raise this as a bug? If so, was it ever resolved?

 

Thanks,

Guillaume.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,019)