0

Apart from Roll-up summary fields , is there any tag to get the count of number of records in a related list?

I suppose we cannot use it like this :

Opportunitycount = Select OpportunityCount__c from Account WHERE id =:selectedaccountId; 

I have an Dropdown of list of Accounts in the org and want to get the value of opportunity/case record count associated with that account upon selection from page.

  • 1
    have you tried SELECT count() FROM Opportunity WHERE AccountId = 'something' ? – Ratan Paul Jan 18 '16 at 11:03
  • 1
    Yep...aggregate SOQL can do this really well. Or querying child relationships from the parent and using List.size() to find the child record count. SELECT Id, (Id from Child_Relationships__r) from Parent_Object__c. @Ratan if you don't write up an answer, I will. ;-) – pchittum Jan 18 '16 at 11:36
  • check out salesforce.stackexchange.com/q/17429/2602 – cropredy Jan 18 '16 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.