TLDR: If you have two record collection variables that have the exact same records, in the same order, how can removing one from the other NOT result in a blank collection?
Full question with background: I have a custom object named Board, with two custom lookup fields to a contact record: Primary__c and Secondary__c. These contacts listed here correspond to community users, so each contacts is associated to a user record via the user record's ContactId field.
I have a screen flow that allows an internal user to change the contacts for a board record. The contacts may be changed in any number of ways, or not changed at all. The flow queries the original users associated with the contacts (sorted by created date, descending) and stores results in a record collection variable called "originalBoardUsers". Then, after the contacts for the board are updated, the flow queries the user records associated with the new contacts with get records element "GetCurrentBoardUsers" (again sorted by created date, descending) and populates a record collection variable called "currentBoardUsers". It is possible that the contacts were not changed by the running user, in which case the values for the two collections should be the exact same.
In the next step, an assignment element works to calculate the users that were removed and those that were added, with the following (among other things):
- currentBoardUsers - REMOVE ALL - originalBoardUsers
- originalBoardUsers - REMOVE ALL - GetCurrentBoardUsers ***
I am using the GetCurrentBoardUsers to update the originalBoardUsers collection since currentBoardUsers is now different than its starting value, due to the prior assignment
Here is the problem: If the user does not change the contacts, then theoretically, removing original from current should result in a blank collection, right? But it doesn't. For some reason, the REMOVE ALL operator leaves only one of the two values in the collection, even though both values are the same.
So the question is: What is going on? How can I make equal collections "cancel each other out"?
(screenshots below. Ignore the "removed" and "added" variables for now)