I'm trying to remove a single record from a record collection variable in a record triggered flow with the setup below, but the Remove All operator isn't working as expected.
The use case is for accounts to have an up to date count of their children accounts using the standard Parent Account field (No_of_children_accounts__c). The idea is that when the Parent Account field is updated, it will fire the flow (which runs after save) to count the total children accounts. There are two parts to this, first update the No_of_children_accounts__c field on the new parent, and then on the previous parent (when/if an account is reparented). The first part works fine, but the second part is where the issue is. So here's what I'm doing for the second part:
- Get Records - to get all children of the previous parent ($Record is being included in this account record collection, even though the $Record has a new parent at this point, not sure why this is happening)
- Assignment - to count the number of children accounts from #1 above
- Assignment - to remove $Record from the record from the collection obtained in #1 above (accountRecordCollectionVariable -- Remove All -- $Record)
- Assignment - to count the number of children accounts after step #3 above (there is no change here, the count still includes $Record)
- Update Record - to update the filed No_of_children_accounts__c for the previous parent.
So that should be pretty straightforward, but for some reason the removing of the $Record from the collection is what is not working. I have other ways to get around this (using a text Id collection variable instead, simply removing one from the count, etc) but for now:
What I am asking for help is specifically understanding why this is not working and what I need to change to remove a record from a collection
Thanks in advance for any and all help!