function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jawtechjawtech 

backend access to related list count?

On the page layout, the number of related list records show on a detail page. From 0 to number of related records. Can we get access to that number from the detail record via a query or property of the relationship? I know we can query from the child such as:

 

 

SELECT COUNT() FROM Contact, Contact.Account
WHERE Account.name = 'MyriadPubs'

 

 

But can we get counts of related objects when querying from the parent? Something like:

 

 

SELECT Name, billingStreet, (select COUNT() FROM Contacts) from Account
WHERE Account.Id = '1234567890kje'

 

 

Ispita_NavatarIspita_Navatar

An easy way of finding the number of related child records would be use of "Summary Rollup fields". If your objects are linked with master detail relationship and you want to find the number of child records for the parent/master  then at the master leavel you can add a "SummaryRollup" type of field which will give count of number of child records for a particular master record.

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.