Is there any way to show the Most recently created child record with its parent record together.
I’m not able to retrieve the children information If I use the Parent as the table model.
However, if I use the child model for this table. Although I can lookup back to its parent record. But in this table, I have no way to filtered out the most recent child record.
Any idea to achieve this?
Off the top of my head I’d say use two models. An aggregate model of the children grouped by parent and ordered by created date, and then another model of the children with all details where their Id is present in the aggregate model
Here’s how you can do it:
Create a model for your parent
In the field picker, select “Child Relationships”. Find your child object and select it.
Your child object will now show up in your field list (on the model). Click it - then you can set some properties.
Select “CreatedDate” on your child object. We’ll use this to get the most recently created child. Select any other fields you want to show (looks like you want to show ChildStatus, so select that.)
While clicked on the Child fields, select Properties. Set the record limit to 1 (so you only get one record) and the Ordered By field to CreatedDate DESC so you get the one most recently created.
Now create your table based on your Parent model. From the model tree up top, drag that child relationship field to your table. then you display fields using the Template merge syntax.
I build an example page using Accounts as the parent, and Contacts as the child. So this table shows the most recently created Contact.
Here’s the xml so you can see how I did it:
Contacts
{{Name}}
Groovy!
Appreciate your helpful answer.
One more question, it seems your solution only works for 1 child record.
Is it possible to make it work for multiple children records as the below image?
Thanks so much.
Poc,
Is there a requirement to show the Child records in 2 columns? The easiest approach is to show 2 records in the same Child record column. Just change the record limit from 1 to 2. You can add the date field to differentiate the entries.
If you must show the child records in 2 columns, you’ll need a custom render for the second column.
Thanks,
Bill
Any example or documentation can refer to the custom render you mentioned? Thanks
Poc,
Take a look at this-> https://docs.skuid.com/v10.0.2/en/skuid/javascript/snippets/table-custom-field.html?highlight=field%…
Thanks,
Bill
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.