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
AndrzejWAndrzejW 

Getting the number of records in a related list

Hi All,
 
I wonder if it is possible to get the number of contacts in an account using a standard controller.  Something like {!account.Contacts.Size}, but obviously this exact syntax doesn't work.
 
Many thanks,
 
Andrzej
sparkysparky
I don't know, and I'm a newbie, but I'm guessing you could write an extension to your controller that included a method that would return that value.

Experts, did I get that right?
Ron HessRon Hess
I think you can do a count rollup field on the account to show this number, then just place it on your page. i normally use sum on a rollup , but think you can do count.
AndrzejWAndrzejW

Many thanks guys!  I will try both suggested solutions.

Andrzej

dchasmandchasman
Spot on Sparky - just a heads up that I logged an enhancement request for myself to provide direct access to things like string length, array/list/map size, etc directly from visualforce formulas but it is still on the todo list.