function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Parker EdelmannParker Edelmann 

Code to Compare Collections and sObject Collections from Visual Workflow

Hello Everyone,

Today, I have a challenge for you all. I'm not a developer and don't have the experience to do this, but I'm very certain that what I'm asking for can be done with Apex. In short, I'd like an Apex class, prefably with Unit Test, that can make this idea, a reality: https://success.salesforce.com/ideaView?id=0873A000000E396QAC

In summary, I'd like to call an Apex class that will compare the values of two collections passed from Visual Workflow. It should four collections: the values that both collections have in common, all the values, the values that are in only the first collection, and the values that are only in the second collection.

The requirements are:
  1. It should be capable of taking two collection variables of the same data type and compare them as described above.
  2. It should be capable of taking two sObject Collection variables and compare them.
  3. For bonus points, it should be able to take a field of an sObject Collection variable and compare it to a Collection, or a field of another sObject Collection variable.
  4. For even more bonus points, it could take an sObject variable or a regular variable, not a collection, compare it to a Collection of the appropriate type, and return true if the sObject variable or variable is a member of the Collection Variable.
I feel like I'm asking for a miracle, but the Spring '17 release is too long to wait for Salesforce to implement this idea, if they decide that quickly to implement it. Let's create our own code so that we can use it, and if Salesforce wants to implement this feature, they can adapt our code to Salesforce standards.

Let's do it!

Best Regards,
Parker Edelmann
SandhyaSandhya (Salesforce Developers) 
Hi Parker Edelmann,

Interesting idea and it is very much useful will try for that.
 
Thanks and Regards
Sandhya