I need to put child names into a text field

So I can display child record names separated by comma in the child-template filed that you can drag in from the field menu of the model, but I need that exact information to be populated into a text field. I don’t need formatting, just the info. How can you get a list of child names separated by comma into a plain text field? Thanks

Here’s an idea, you can select a child relationship on a model under the “Fields” section. Select your child relationship and set up a field renderer snippet. This may not be so efficient but it’ll probably work…


var field = arguments[0], <br>&nbsp; &nbsp; value = arguments[1], &nbsp; &nbsp;<br>&nbsp; &nbsp; $ = skuid.$,<br>&nbsp; &nbsp; row = field.row<br>&nbsp; &nbsp; Id = row.Id;<br>var str = "";<br>$.each(row.ChildRelationship.records, function(i, rec){<br>&nbsp; &nbsp; if(rec.ParentId == Id){<br>&nbsp; &nbsp; &nbsp; &nbsp; str += rec.Text_Field__c + ","<br>&nbsp; &nbsp; }<br>});<br>value = str;<br>//render field etc...




Thanks Moshe! I’m not a strong coder, but I couldn’t get this code to work. It breaks the page. It seems like I could do this through a model action.: Every time the model is queried or saved or a new row created update row in model. I tried it, but the text field stays empty. I’m thinking I may not be using the right merge text. This is what displays in the child template that I dragged from the field menu.: {{Chronic_Condition__r.Name}} Can I set a text field equal to this using an action? If so what merge text would I use?

Try some console.log()'s to see what you’re getting. I belive that your loop should look like this:

$&#46;each(row&#46;Chronic_Condition__r&#46;records, function(i, rec){<br />console&#46;log(rec);<br />&nbsp; &nbsp; if(rec&#46;ParentId == Id){<br />&nbsp; &nbsp; &nbsp; &nbsp; str += rec&#46;Name + ","<br />&nbsp; &nbsp; }<br />});<br />console&#46;log(str);



etc… also replace ParentId with the correct API Name

Thanks again, Moshe. As always, I appreciate everyone’s help. After a bunch of searches on the community, I came across this post: https://community.skuidify.com/skuid/topics/use_merged_child_fields_in_event_template_on_calendar I added a model action that updates my text field with the child reference illustrated in this post and it works beautifully. Thanks!

Glad to hear that you got it working! 

I used to code Matt wrote for referencing a single record, then strung together five of those so I could get five comma separated values. I couldn’t t get the following code to work if I have to reference the model. I want to use it in a template in a table of a different model. If you could tell me how to reference a child record set from outside the model, that would be helpful for future uses. Thanks! {{#EventRelations.records}}{{Relation.Name}}
{{/EventRelations.records}}