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> value = arguments 1], <br> $ = skuid.$,<br> row = field.row<br> Id = row.Id;<br>var str = "";<br>$.each(row.ChildRelationship.records, function(i, rec){<br> if(rec.ParentId == Id){<br> str += rec.Text_Field__c + ","<br> }<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:
$.each(row.Chronic_Condition__r.records, function(i, rec){<br />console.log(rec);<br /> if(rec.ParentId == Id){<br /> str += rec.Name + ","<br /> }<br />});<br />console.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.skuid.com/t/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}}
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.