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.

({{$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.

- 460 Points

Posted 3 years ago

Skuidward Tentacles (Raymond), Champion

- 17,786 Points

You should be able to do a UI only field that adds the lengths together, then reference that field in your tab name.

- 206 Points

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/skuid/top...

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?

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/skuid/top...

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?

Skuidward Tentacles (Raymond), Champion

- 17,786 Points

- 206 Points

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}}

{{$Model.ModelName.data.length}}

(Edited)

Skuidward Tentacles (Raymond), Champion

- 17,786 Points

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.

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.

- 206 Points

That worked like a charm. I was going wrong on both points you made. Thanks so much for the help!

Skuidward Tentacles (Raymond), Champion

- 17,786 Points

- 206 Points

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/skuid/top...

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?

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/skuid/top...

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?

Skuidward Tentacles (Raymond), Champion

- 17,786 Points

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/skuid/top...

There was no response from Skuid support.

I would report it as a problem as a community post and see what they say.

https://community.skuid.com/skuid/top...

There was no response from Skuid support.

I would report it as a problem as a community post and see what they say.

Skuidward Tentacles (Raymond), Champion

- 17,786 Points

Pat found syntax that worked for Nulls. See this post.

https://community.skuid.com/skuid/top...

https://community.skuid.com/skuid/top...