Custom code to count associated records.

There’s a way to do this without “custom code”.

  1. On the custom object, create a calculated property called “Power of One” (this is how I’ve heard it referenced elsewhere) that’s a custom equation and always equal to “1”.
  2. On the company object, create a calculated property called “Number of Associated [custom object]” that’s a Count equation that counts up all the 1’s of the “Power of One” porperty.