You need to sign in to do that
Don't have an account?
Ashwani Pradhan
How to check frequency of item in List?
I have a list with duplicate elements like below -
List<Contact_c> corr = [SELECT Contact_r.Name, Id, Name From Contact_c];
Now in result of corr getting same Contact_r.Name multiple times and I need to show all those contacts whose occurrence in list > 1
If I group Contact_r.Name and try to count then list will only give contact one time which will force me to query in loop to get all and heap size issue occuring.
If I am trying to use Map to occurrence then again heap issue came.
So I have only one option left that any how in corr iteration I can check frequency of Contact_r.Name in corr and if its greater than 1 then show record else continue
Please help me how can we achieve under Apex.
List<Contact_c> corr = [SELECT Contact_r.Name, Id, Name From Contact_c];
Now in result of corr getting same Contact_r.Name multiple times and I need to show all those contacts whose occurrence in list > 1
If I group Contact_r.Name and try to count then list will only give contact one time which will force me to query in loop to get all and heap size issue occuring.
If I am trying to use Map to occurrence then again heap issue came.
So I have only one option left that any how in corr iteration I can check frequency of Contact_r.Name in corr and if its greater than 1 then show record else continue
Please help me how can we achieve under Apex.
OR
All Answers
OR