Category: Question and Answers
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Count Query Returns

Issue

I need to include the result of a query called "count_Active-Clients" in a chart. I want to know how to get the total number of records returned by the query so I can use the count in the chart. Amelia suggested using "count_Active-Clients.data.length" and it worked. I'm new to JS scripting and am wondering if there are tutorials available. Also, I'm curious if there's a way to have a common query and pass the Where condition through the script. Thanks to Amelia for the help.

Resolution

During a conversation with Amelia, Ben has added a query "count_Active-Clients" and wants to know how to get the total number of records returned by the query so that he can use the count in a chart. Amelia suggested using "count_Active-Clients.data.length" to get the total number of records returned by the query.

Additionally, Ben asked if there were any JS scripting tutorials available and if it was possible to have a common query and pass the "where" condition through the script. Amelia shared some helpful documentation with Ben on Writing Code in Appsmith and Data Access and Binding.

In summary, to get the total number of records returned by a query in Appsmith, you can use "queryName.data.length". Appsmith also offers helpful documentation on writing code and data access and binding. It is possible to have a common query and pass the "where" condition through the script.