Count number of child object records in Salesforce

Six 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
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
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
Highlighted
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

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Downloads and Trials

Test drive Talend's enterprise products.

Downloads