Template repeating child relationship data in table

I’m using a field form a child relationship to the model and am including it in a table via template. The data being returned is duplicating itself though. I’ve attached what is going on. How the template is set and the results. Any help is appreciated.

Have you tried using three curly braces instead?


Sometimes that fixes these sorts of issues as it removes the field formatting - if not, I’m sure someone else will point you in the right direction!

Three curly braces still does the same thing.

If there are multiple child rows in the child model, a template field will display a value for every row. Do you only want to see it once? You can probably do that with Javascript.

Moshe - Yep, shooting for seeing it once.

If the document name of the child record is always the same could you pass it up to the parent using a cross-object workflow and then just use the parent field in the table? I guess that’s not particularly elegant…

OK try something like this:
1) Drag a random text field into the table, hook up a custom field renderer javascript snippet.
2) In the snippet code like so:

var field = arguments[0],    
    value = arguments[1],
   $ = skuid.$;
// this should be your child relationship model
var yourModel = skuid.$M(‘YOURMODELNAME’);
var yourFirstRow = yourModel.getFirstRow();
value = yourModel.getFieldValue(yourFirstRow,‘c2g__Invoice__r.Name’);

Moshe’s way would work, but you’d have to create a separate model for your child rows.  It looks like right now you’re using a Child Relationship field.  The way your data model is set up seems a little strange, but if it needs to be that way, I’d take this approach…

Instead of dragging a Child Relationship field into your table, just drag a plain old template component in there.  For your template text, use…


Also, if you’re only using the first Child Relationship record returned, I’d make sure to set the “Max # of Records (Limit)” to 1.  This way your page will be as efficient as possible.

Ben - your answer took care of it. Thank you. And thank you to others for your help.

Agreed with Ben, the best way to do this would be to set the “Max # of Records (Limit)” to 1 on your Child Relationship, from its “Properties” area. Then you don’t have to drag in a Template, you can just go back to dragging in a regular Child Relationship, which is a little simpler to work with.

Somewhat related question.  I have also posted a separate question for this but may be you can help.

I am trying to set a condition on the Child Relationship field.  This is in addition to limiting the number of records to 1.  My condition works if I set it by specifying a specific value for <= condition.  But if I use this to compare against a field from a source model it does not work.  Looks like the source model does not get evaluated in time.  The same source model does return a record and I have verified that by just associating that field in a field editor.  But the child condition does not work since source model apparently returns 0 records.

Any ideas?

Hi, Milind,
So, if I understand correctly, you have a parent model and child model, and the parent model has a condition where Id = the lookup field in any row returned by the child model. In your list of models, is the child model (the source model) listed before the parent model?

Thanks for the reply.  I did figure that out and it started working when the model that provides the rows for a condition is listed before the model that uses the condition.

The only problem that remains is when I update the source model that provides rows for a condition in a chidlrelationship field in another model it does not automatically use the updated rows from the source model even when I query the model again using action framework.

Looks like the condition defined using “user rows from source model” only sets it initially.  If the source model changes it does not update the condition.  I could write a small java script code to force that when my source model changes but I was assuming that requerying the model would make sure that the conditions are also reevaluated using the updated source or at least there is a way to force it in action framework.

May be you can consider it as an item for Action FW enhancement.

Thank you

I think another one of our other customers just brought up a similar issue! It looks like this is a bug, and one of our product developers has looked into it. Requerying the model should definitely update the data to reflect the updated condition. One thing to note: If you don’t need your model data directly on page load, I think the models may actually work correctly if you set “Load model data on page load” to false for these models, and then query them when you need them? Not ideal, but it might be a workaround for now. Thanks for reporting this!