JHatza
Scholar

Count number of items on a list page

Jump to solution

On a list page, how do I count the number of items for a specific date (that I get from url querystring) using jquery?

0 Kudos
5 Replies
Jake
Nintex for Sharepoint Expert
Nintex for Sharepoint Expert

Re: Count number of items on a list page

Jump to solution
Hi there,

You might not need to use jquery, it would depend perhaps on your use case and what you would want to do, could you explain more?
0 Kudos
JHatza
Scholar

Re: Count number of items on a list page

Jump to solution

I have got a list of subscribers grouped by date. You can subscribe for a date to the list by submitting a nintex form. The redirection page when submitting the form is the list page to which I add the date into the url, for example "listpage?date=09052022".

When loading the listpage, if date into url querystring is note empty, it would count the number of subscribers for that date, for example for the 09052022. If the number of subscribers is over 24 for the 09052022, it would show an alert message "There is no more rooms for the 09052022. Please delete and register for another date".

0 Kudos
SimonMuntz
Nintex How-To Center Expert
Nintex How-To Center Expert

Re: Count number of items on a list page

Jump to solution
Hi,

You can use a calculated value control on the form that returns the number of items on the list for that date.
The function would look like this: count(lookup("NameOfList","Date","09052022","ID",true))
If you are using a classic form you could capture the output as a JavaScript variable and then use it in a Javascript function to pop up the warning and disable the submit buttons.
0 Kudos
JHatza
Scholar

Re: Count number of items on a list page

Jump to solution

Great, thank you!

How can I capture the output in a javascript variable? Please advice.

0 Kudos
SimonMuntz
Nintex How-To Center Expert
Nintex How-To Center Expert

Re: Count number of items on a list page

Jump to solution

Hi.

In the advanced section of the Calculated Value control you can configure the control to capture the output in a variable.

Also as you are capturing the date from the URL you can populate a control on the form with the value and then add the control name to the formula I previously provided to make it dynamic.

Something like:  count(lookup("NameOfList","Date",ControlNameHoldingDateFromURL,"ID",true)).

1. The form loads. 

2. A control is populated with a date from the URL

3. The calculated value control returns the number of items with that date.
4. The custom javascript Pops up a message if the value equals a certain limit and the submit button is disabled based on a rule which looks at the same value from the calculated value control.


JSVar.png

0 Kudos