Count of Child records on ContentDocument Object

  • 1
  • Question
  • Updated 3 years ago
I have built a file manager that organizes and executes various actions on the ContentDocument object and related objects including delete, edit, contribute to library, deliver,and preview. The main table is based on ContentDocument object. Content Document has a child relationship with ContentDistribution which stores the Content Delivery information. Now I have a column displaying the names of the content deliveries via the child ContentDistribution object in comma separated form. This is fine, but ultimately I want to just display the number of records because I have a row action that brings up a pop up displaying all of the current deliveries for that ContentDocument and the ability to add new deliveries in the popup, so displaying the names in the main table is redundant.
How can I display the number of child ContentDistribution records in a table of the parent object ContentDocument? Thanks
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Travis

Travis

  • 70 Points
I just got this working this week:

1. Setup a parent model.
2. Setup the child model Model Behavior set to Aggregate and then get the count you need.
3. Create a UI only field for the parent model.
4. Make the field use a Display Type of Formula
5. Then do a model lookup like: MODEL_LOOKUP("ChildModel","ReturnChildField","SearchChildField",{{Id}})

Hope it helps.
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
I'll give it a try. Thanks!