​​​​How to retrieve number of items in the current list?

Last Update: December 12, 2017

Here are the steps on how to retrieve the number of items in the current list and save the result into a Textbox:

  1. ​Open your list in design mode.
  2. Add a textbox control to the form design workspace and name it txtItemsCount.
  3. Select the Form by clicking on any empty space on the form design workspace area.
  4. In the Rules pane, click on the Add icon to add a new rule, the Rule Manager dialog will open.
    How to auto-shifting Panel control in a form2.jpg
  5. 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 = (getCurrentListFieldData('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.
  6. Test the form by clicking on the Preview button in the View Group.