How to retrieve number of items in a specific list?
Last Update: December 12, 2017
Suppose you are working on a list named "Priorities" located at the root site and you want to save the number of items of this list into a textbox when loading the form. Here are the steps on how to do that:
- Open your list in
design mode.
- Add a textbox control to the form design workspace and name it txtItemsCount.
- Select the Form by clicking on any empty space on the form design workspace area.
- In the
Rules pane, click on the Add icon to add a new rule, the
Rule Manager dialog will open.

- Add a new rule as follows:
A. Update the
Rule Name as desired.
B. Change the
Rule Type to Action.
C. Keep the
Event Type onLoad.
D. In the Action section, type the following script:
var Items_array = (getListFieldData('/', 'Priorities', 'ID',""));
setValue(txtItemsCount,Items_array.length);
E. Click on the Save button to save the rule.
Note: You can use
Assistance Panel to help you adding functions and related parameters, form variables and form controls to
Conditions and/or
Actions sections. - Test the form by clicking on the Preview button in the View Group.