cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sascha2
Frequent Visitor

ForAll - ThisRecord broken?

I have a piece of code which was definitly working fine 2 days ago, now is completely broken. I have tackled it down to be a broken funcktionallity in Combination of "ForAll" and "ThisRecord". I have prepared a simplified code snippet to show the issue:

 

 

 

ClearCollect(Collection1;Table({ID:1};{ID:2};{ID:3}));;
ClearCollect(ItemsToRemove;Table({ID:2}));;


ForAll(ItemsToRemove;
    Notify("ID of Record of ItemsToRemove-Collection:" & ThisRecord.ID & " - this is correct." & Char(13)&
    "ID of Looked up Value in Collection: " & First(Filter(Collection1;ID=ThisRecord.ID)).ID &". This is incorrect. Should be 2, not 1" 
));;

 

Put this snippet on a button and you will be able to reproduce the issue.

 

I am pretty sure this is a major bug which was introduced within the last 48 hours.

This has enourmos impacts. LookUps / Filters / RemoveIf to a SQL Server Database will have the exact same issue and affect random records. Due to this, our Canvas App is currently deleting random records from a SQL Server Database instead of selected ones.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
AmDev
Super User
Super User

Hi @Sascha2 

 

It might be something to do with the nested 'ThisRecord' which is causing conflicts.

 

Can you try redefining your source using the 'As' function, so you can use something other than ThisRecord and potentially avoid conflicts - in this example I have just called it 'ITR'

 

ClearCollect(Collection1;Table({ID:1};{ID:2};{ID:3}));;
ClearCollect(ItemsToRemove;Table({ID:2}));;


ForAll(ItemsToRemove As ITR;
    Notify("ID of Record of ItemsToRemove-Collection:" & ITR.ID & " - this is correct." & Char(13)&
    "ID of Looked up Value in Collection: " & First(Filter(Collection1;ID=ITR.ID)).ID &". This is incorrect. Should be 2, not 1" 
));;

 

 Hope this Helps

View solution in original post

2 REPLIES 2
AmDev
Super User
Super User

Hi @Sascha2 

 

It might be something to do with the nested 'ThisRecord' which is causing conflicts.

 

Can you try redefining your source using the 'As' function, so you can use something other than ThisRecord and potentially avoid conflicts - in this example I have just called it 'ITR'

 

ClearCollect(Collection1;Table({ID:1};{ID:2};{ID:3}));;
ClearCollect(ItemsToRemove;Table({ID:2}));;


ForAll(ItemsToRemove As ITR;
    Notify("ID of Record of ItemsToRemove-Collection:" & ITR.ID & " - this is correct." & Char(13)&
    "ID of Looked up Value in Collection: " & First(Filter(Collection1;ID=ITR.ID)).ID &". This is incorrect. Should be 2, not 1" 
));;

 

 Hope this Helps

Sascha2
Frequent Visitor

Thanks, indeed using the Alias here seems to solve the issue. I'll implement that. Thanks so far.

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.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,787)