Greater than formula for a maximum # of lines


Badge +6

Hello!

I am creating a repeating section for cost centers.

fn-GreaterThan()

I want the formula to make it so that the maximum amount of repeating lines is no greater than the amount of choices selected in a previous question i.e. if they choose 5 states, there should only be 5 cost centers but if they choose 10 states there should be 10 cost centers. Is using "Greater Than" the start of the formula or should I use something else? How can a make a formula that fits what I want to do?


8 replies

Badge +11

Hi Jennifer Smith

You cannot reference the form field in the repeating section maximum rows configuration. You can create a formula but cannot reference another field to restrict it.

see this for reference as a start:  

Badge +6

Thank  you. Unfortunately I do not know javascript

Userlevel 5
Badge +14

maybe it's not exactly what you figured out, but if you want to avoid any javascript it might be sufficient for you ...

so try following.

there is a currentRowNumber() runtime function which can count rows in repeating section.

so, add a calculated value control and set  its formula to calculate current row number

eg.

204198_pastedImage_2.png

next, just to have some content in repeating section I added a text box  and named it 'text'

note this control was used in above formula

204199_pastedImage_3.png

then I added one another calculated value control to provide a warning if max number of rows is exceeded

204200_pastedImage_4.png

to get max number of possible rows I added a text control out of repeating section and named it MaxLines

204201_pastedImage_5.png

finally I set up two formatting rules which show/hide either 'content' control or warning message

rule for content control

204202_pastedImage_6.png

and rule for warning message with opposite logic

204203_pastedImage_7.png

overall setup looks like this

204197_pastedImage_1.png

Badge +6

Can the max lines be different for each submission based on the answer to the previous question? If person A chooses 5 markets the max amount of cost centers he can enter is 5. However, if person be selects 10 markets the max amount of cost centers he can add is 10.

Userlevel 5
Badge +14

sure!

have a closer look on my example - I have there a input box (named MaxLines) above repeating section that defines how much entries are max allowed within repeating section.

I used 3 in that example.

Userlevel 5
Badge +14

Hi ‌, did this worked for you?

Badge +6

Hi! ‌ I ended up going a different direction so I didn't try this one.

Badge +11
What was the solution in your case? I am after similar approach ... when user selects: 3 Items then the repeated section should not allow to add more than 3 rows.

Reply