1
0
-1

Hi - what's the recommended way to get the number of instances in a repeat?

I have a form where they would like to hide the heading if there is only one instance, but show it if there is more than one. Would we just get the length of the array returned from Form.getRepeatData(...) ?

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi Daniel,

      It is as simple as getting the length of the repeat array.

      So "data.repeat.length"

      Ensure that the item data you are referencing is the repeat.

      1. Daniel Carlier

        Thanks Dave, however that doesn't seem to be working for me:

        I've created a sample form:

        https://maestro.avoka.com.au/maestro/secure/design/8567

        I've got a visibility rule on the Repeat Header Block inside the repeat. data.contentrpt is coming back as undefined so I can't get the length of it.

        If I do: 

        $("Form").scope().Form.data.contentrpt.length

        from the console it's always returning 1, regardless of the number of instances. Could you please let me know what the code should be to get the repeat length from inside the repeat?

        Cheers,

        Dan

      2. David Moore

        If you are within the repeat you need to jump up to the parents data object.

        data.$p.contentrpt.length

        Please watch this video that explains how repeating data in Maestro works.

        https://vimeo.com/211605247


      3. Daniel Carlier

        Cheers Dave, that worked. However when I double click a repeat from a visiblity rule for an element inside the repeat, it was referring to it as data.contentrpt, not data.$p.contentrpt. I'll raise a ticket?

      CommentAdd your comment...