function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Hi All,
How to get the total count of all contacts with atleast one related Case.
Thanks
hi,
Did you try the sub-query route?
Use the following code:
list<case> casList = [select id, caseNumber,contactId from case];system.debug('-----------'+casList.size());set<id> casSet = new set<id>();for(case c: casList){casSet.add(c.contactId);}system.debug('-----------'+casSet.size());
"casSet.size()" contains the count of all cases with atleast one related case attached to it.
HI hch,
I think contactid in not mandatory in th Case object. I got Zero list size
If you get zero list size then there are no cases in your org. And if you get the set size as zero then there are no cases associated with the contact.
hi,
Did you try the sub-query route?
Use the following code:
list<case> casList = [select id, caseNumber,contactId from case];
system.debug('-----------'+casList.size());
set<id> casSet = new set<id>();
for(case c: casList){
casSet.add(c.contactId);
}
system.debug('-----------'+casSet.size());
"casSet.size()" contains the count of all cases with atleast one related case attached to it.
HI hch,
I think contactid in not mandatory in th Case object. I got Zero list size
If you get zero list size then there are no cases in your org. And if you get the set size as zero then there are no cases associated with the contact.