Count number of list items in a field

Forums Dynamic Forms for SharePoint Count number of list items in a field

Viewing 1 reply thread
  • Author
    • #31531
      Jeremy Smith

      I would like to setup an alert message that tells me when a field has more or less than x number of items in a sorted or unsorted list

      Example: Field = remainingTasks
      In field there is a list of items present and I want to count how many list items (sorted or unsorted) are existing in that field when I enter the form

      I tried these examples but could figure out how to properly adapt them to work:

      //Counts the number of List Items in a field
      var theList = document.querySelector("[id*='remainingTasks_']");
      var theList = document.getElementByRegex("^remainingTasks_.*").getElementsByTagName("ul");
      var numberOfItems = theList.length;
    • #31546
      Alexander Bautz

      Is this a multiline rich text field where you want to count <li> elements?

      If so, try this:

      var html = jQspjs(getFieldValue("YourNoteFieldInternalName"));
      var len = jQuery(html).find("li").length;

      Replace YourNoteFieldInternalName with the internal name of your multiline field.


Viewing 1 reply thread
  • You must be logged in to reply to this topic.