cancel
Showing results for 
Search instead for 
Did you mean: 
Hongo-Sanchome
Nintex Newbie

Restrict Repeating Sections

I have a form with a repeating section called "Market", and in that repeating section I have a Choice field with 5 Markets - let's say UK, Fr, Es, De & It - so that the user can enter details in the form for any of those different markets. However, I do not want the user to enter a Market more than once - i.e. the maximum number or repeating sections is 5, where each section is a unique Market. How do I prevent users from creating multiple repeating sections with the same Market?

Labels: (1)
0 Kudos
Reply
7 Replies
Nintex Employee
Nintex Employee

Re: Restrict Repeating Sections

Hi,
This is possible but might be a little messy.
Controls in a repeating section can be referenced like an array that is zero indexed.
I tried creating a rule based on that fact but the rule did not seem to work.
I then tried to create a calculated value that would be true if two entries were the same.
The calculated value function looked like:
Market[0]==Market[1]||Market[0]==Market[2].......
Then add a rule to check if the Calculated value returns true.
It works.

The whole function would look like below with Market being a named control.

Market[0]==Market[1]||Market[0]==Market[2]||Market[0]==Market[3]||Market[0]==Market[4]||Market[1]==Market[2]||Market[1]==Market[3]||Market[1]==Market[4]||Market[2]==Market[3]||Market[2]==Market[4]||Market[3]==Market[4]
0 Kudos
Reply
Hongo-Sanchome
Nintex Newbie

Re: Restrict Repeating Sections

Thanks Simon, but honestly I don't think I have enough information here to pull this off. I understand the theory, but (a) I'm not sure if the calc value should go in the main section of the form or the repeating section, and (b) where the rule would go.

 

I've created a calc value with the below function (my country selector control in the repeating section is called "MarketLATAM"), but if I put this calc value in the main section of the form it always returns "1", and if I put it in the repeating section, it returns "1" until I select any country, and then it always returns "0" - even if I have multiples of the same country - unless I select the 3rd country (Colombia), in which case it's always "1" whether or not there are multiples of that third country.

 

If((MarketLATAM[0]==MarketLATAM[1]||MarketLATAM[0]==MarketLATAM[2]||MarketLATAM[0]==MarketLATAM[3]||MarketLATAM[0]==MarketLATAM[4]|| MarketLATAM[1]==MarketLATAM[2]||MarketLATAM[1]==MarketLATAM[3]||MarketLATAM[1]==MarketLATAM[4]||MarketLATAM[2]==MarketLATAM[3]|| MarketLATAM[2]==MarketLATAM[4]||MarketLATAM[3]==MarketLATAM[4]), 1, 0)

0 Kudos
Reply
Nintex Employee
Nintex Employee

Re: Restrict Repeating Sections

The calculated value control goes outside of the repeating section.
No If() runtime function reqiured.
Just use the function like I had in my previous post. It outputs true or false so no need to add a layer of complexity and make it output a 1 or 0.
0 Kudos
Reply
Hongo-Sanchome
Nintex Newbie

Re: Restrict Repeating Sections

OK: understood - thanks. I have this partially working, in that it totally works if I use this 1st part of the function - Market[0]==Market[1]||Market[0]==Market[2]||Market[0]==Market[3]||Market[0]==Market[4]||Market[1]==Market[2]||Market[1]==Market[3]||Market[1]==Market[4]

But when I add the next part - ||Market[2]==Market[3] - then the form invalidates even if I only have 2 markets and both of those markets are different.

Is this because if I've only added 2 repeating sections then Market[2] == Market [3] in the sense that they're both empty?

0 Kudos
Reply
Hongo-Sanchome
Nintex Newbie

Re: Restrict Repeating Sections

Another thought: the function won't scale beyond 5 repeating sections - i.e. any number of repeating sections created >5 won't be checked.

0 Kudos
Reply
Hongo-Sanchome
Nintex Newbie

Re: Restrict Repeating Sections

To answer my own question, I used to the below formula to prevent folks from adding more than 5 repeating sections:

 

if(count(Market)>5,true,false)

0 Kudos
Reply
Hongo-Sanchome
Nintex Newbie

Re: Restrict Repeating Sections

To answer my own question - yes: if 2 compared Markets both equal null, then the Calculated Value returns True. So, I've revised the formula as follows, which appears to work correctly:

Market[0]!=null&&Market[0]==Market[1]||
Market[0]!=null&&Market[0]==Market[2]||
Market[0]!=null&&Market[0]==Market[3]||
Market[0]!=null&&Market[0]==Market[4]||
Market[1]!=null&&Market[1]==Market[2]||
Market[1]!=null&&Market[1]==Market[3]||
Market[1]!=null&&Market[1]==Market[4]||
Market[2]!=null&&Market[2]==Market[3]||
Market[2]!=null&&Market[2]==Market[4]||
Market[3]!=null&&Market[3]==Market[4]

Reply