Hi, I have multiple related lists organized into tabs on my Skuid Account page and I like to include the number of records located inside each tab so that users can quickly see how many records are in a tab without clicking on it. I do this by putting the following in the tab custom label
({{$Model.Contacts.data.length}})
This produces a tab that shows Contacts (3) in the tab name. My question is; if I have a tab with multiple models inside of it. ie. a Notes and attachments tab, what is the best way that I sum those together to produce one number for my tab label.
ie. if I have 4 notes and 6 attachments for an account, how can I sum ({{$Model.Notes.data.length}}) and ({{$Model.Attachments.data.length}}) to produce “Notes & Attachments (10)” in the tab label.
You should be able to do a UI only field that adds the lengths together, then reference that field in your tab name.
Dave - were you able to make Raymond’s suggestion work? I have been trying to accomplish the same thing with no luck. I tried creating a UI only formula field (numbe format) to add together the lengths of two data models but when I used {{Model.ModelName.data.0.length}} the page won’t load at all. I tried some other ideas like: 0+{{Model.ModelName.data.0.length}} and {{Model.ModelName.data.0.length}}+0 When I use the same syntax in a Rich Text element I do get the length of each data model like so: Model 1 = 12 rows Model 2 = 18 rows I also attempted the process discussed on this post: https://community.skuid.com/t/adding-two-ui-only-formula-fields-from-different-models This allowed me to “add” to the two data sets together but it returned “1218” rather than “30”. Any ideas on where I might be going wrong?
Try a dollar sign in front of model: {{$Model.ModelName.data.0.length}}
sorry. I had 2 typos in my comment. I do have the dollar signs in the syntax and i do not have “data.0.length” but rather “data.length” like this: {{$Model.ModelName.data.length}}
Try wrapping each with VALUE: VALUE( {{Model.ModelName.data.0.length}}) Also, make sure that the model the UI only field is in loads AFTER the model you are referencing in this formula.
That worked like a charm. I was going wrong on both points you made. Thanks so much for the help!
Great, you are welcome!
Raymond , I found a small wrinkle… If the count from “Model 1” is 5 and the count from “Model 2” is 7, then I get the correct value of 12 when summing the two models. However, if the count from “Model 1” is 5 and the count “Model 2” is null/zero then the formula does not produce a result. Is there a way to evaluate this? I referenced this post but did not have much luck. https://community.skuid.com/t/how-can-i-test-a-numeric-ui-only-field-for-null-in-a-formula-for-another-ui-only-field I tried these options as well to evaluate null/zero and produce a 0: IF({{$Model.Model1.data.length}}==null,0,VALUE({{$Model.Model2.data.length}})) IF({{$Model.Model1.data.length}}==0,0,VALUE({{$Model.Model2.data.length}})) IF({{$Model.Model1.data.length}}>0,VALUE({{$Model.Model2.data.length}}),0) Is this a limitation of skuid or is there a way to evalute?
Pat is pretty handy with Skuid and he reported a problem with formula fields not handling null values in this post: https://community.skuid.com/t/formula-field-wont-calculate-null-value?topic-reply-list[settings][filter_by]=all&topic-reply-list[settings][page]=1#reply_16986449 There was no response from Skuid support. I would report it as a problem as a community post and see what they say.
Pat found syntax that worked for Nulls. See this post. https://community.skuid.com/t/formula-field-wont-calculate-null-value?utm_source=notification&utm_medium=email&utm_campaign=new_comment&utm_content=reply_button&reply[id]=16986512#reply_16986512
That did it. Thanks so much Raymond and Pat.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.