Render Conditions to include count of records in a related model

edited June 25, 2020 in Questions
I have a a need to render some different layouts depending on the number of child records on the parent object. e.g. if the parent has only 1 child, the page is shown as 'one', where we mash up the two records into a single view. Between 2 and 4 we nest the children below, and more than 4, we provide a list.

How do I create the render condition that queries the number of records in a model?


  • Zach McElrathZach McElrath Principal Software Engineer Chattanooga, TN 💎💎💎
    edited June 25, 2020
    Option 1: create a Roll-up Summary field on your parent model called "# of Children", that just does a COUNT on the number of children. Then you could base your Render Conditions on the "# of Children" field on the parent Model.

    Option 2: use JavaScript to listen for row creation / deletion events on the parent Model and then apply your own custom logic to decide which components to render / unrender. We can provide a code snippet for this if Option 1 won't work, but I'd recommend Option 1, as it's the path of least resistance.
  • edited September 1, 2014
    Thanks Zach! Will try for option 1 for now.
  • Pat VachonPat Vachon 💎💎💎
    edited January 5, 2016
    I've the same requirement but I've got just one table where the lookup is to itself. So Roll-up summary. Could I have that code snippet?
  • edited November 19, 2015
    And I need to show a message when the number of child records is less than what is expected, which is based on a value on the parent record, and I can't use a roll-up summary because this is to manage/count daily attendance records.
  • Rob HatchRob Hatch 💎💎💎
    edited September 1, 2016
    Note.  As of the Superbank release it is now possible to specify rendering conditions based on number of rows in a model.  If rows = 0 show component A,  If rows=1 show component B, if rows = 2 show component C etc. 
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!