Calculate number of rows in a model

Hello again! I’ve a snippet which spits out a random selection of rows from a model but, to tidy it up, I need to know the total number of rows in a model (on the contact object).

I can’t use a roll-up summary on the account as it doesn’t work for the contact object so this needs to be done in javascript - is there a nice way of doing this using the API - or do I loop through the rows and count them?



We do have a way to get that count from the JS API. Each Skuid model contains an array named “data,” which contains the rows within in the model. For instance, if your model is named “Contacts,” you can get the number of rows as follows:


Our skuid.model.Model api documentation contains the official write up. I hope that helps.

Perfect, thanks guys.

No problem! I’m glad we could help.