Count number of child object records in Salesforce

Five Stars

Count number of child object records in Salesforce

Hi. In Salesforce CRM is kind of difficult to have field on parent object record summarizing child object records like Count, Sum, Max, Min, etc unless you use Master-detail relationship, which comes with other limitations so it cannot be always used. I was thinking I could use Talend to calculate this instead and inject the values into parent object record. On Account-Contact example I wanted to use following query (talking about Count now)

"SELECT AccountId,count(Id) FROM Contact GROUP BY AccountId"

which would give me the Contact count that I could inject into the Account record. However this fails because of "Aggregate query does not support queryMore()".

I dont know how to go around this, can someone help me or Im open to take completely different approach if you have idea and it leads to what I need. Thank you very much


Accepted Solutions
Highlighted
Fifteen Stars TRF
Fifteen Stars

Re: Count number of child object records in Salesforce

As aggregate relationships are not supported in salesforce Bulk Query (which is a way to avoid any call to the queryMore() method), I'm afraid you have to query all Contact records (based on your example) to get Id and AccountId fields and use the tAggregateRow component to compute the number of Contact for each Account.


TRF

All Replies
Highlighted
Fifteen Stars TRF
Fifteen Stars

Re: Count number of child object records in Salesforce

As aggregate relationships are not supported in salesforce Bulk Query (which is a way to avoid any call to the queryMore() method), I'm afraid you have to query all Contact records (based on your example) to get Id and AccountId fields and use the tAggregateRow component to compute the number of Contact for each Account.


TRF
Fifteen Stars TRF
Fifteen Stars

Re: Count number of child object records in Salesforce

@Lukas, does this help?

If so, thanks to mark your case as solved (Kudos also accepted as a bonus)


TRF

Cloud Free Trial

Try Talend Cloud free for 30 days.

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.