Limit Confiforms form to one or two entries depending on checked check box and exiting entries
Asked by JN:

Hi,

I would appreciate some assistance with a Confiforms form, I used the below link with a slight adjustment to limit the entries to two entries per date:

<https://wiki.vertuna.com/display/CONFIFORMS/ConfiForms+Form+to+allow+only+one+entry+per+user+per+month>

how do I go about enhancing that to limiting the entry per date to one or two entries depending on a check box being checked and if there is already an entry on the date?

Many Thanks

Jonathan


Answers:
author: Alex Medved _ConfiForms_
body: The easiest os to have 2 rules with slightly different conditions.. unless you can put everything into one condition

```
mydate:[entry._today] AND mycheckbox:true AND _count:>2
```

Or whatever conditions you need...

More on filters (as these are used as conditions) you can find on our wiki - <https://wiki.vertuna.com/display/CONFIFORMS/ConfiForms+Filters>

Alex

comments: author: JN
body: Hi Alex,

This works for when the user tries to enter a second entry with the check box checked but if there is already an entry with the check box check on that day I don't want to allow any further entries, how do I include that in the condition or reference it in another condition?

Thanks

J


author: Alex Medved _ConfiForms_
body: If I get you right then you need to check for _count:\>1 instead


author: JN
body: I have it as this:

Date:\[entry._today\] AND ChangeControl:true AND _count\>1

This is running as the condition in a "Confiforms rules for Field Definition" where "Date" is the field name and "ChangeControl" is the check box in the form and what I want to validate against in the data already possibly specified on that date currently in the dataset.

Currently the form will not allow two entries with check boxes ticked but it will allow one ticked and one not (or two not which is fine) but I only want to allow one entry with the check box checked per day.

Thanks again


author: Alex Medved _ConfiForms_
body: You will need a condition like this

```
(Date:[entry.Date] AND ChangeControl:true AND !id:[empty] AND _count:>=1) OR (Date:[entry.Date] AND _count:>2)
```

Alex


author: JN
body: Thanks Alex, this works great in all cases except when an entry exists on a date without a checked box and you add an entry that has the check box selected - it allows it and I don't want it to!

Interestingly if I open the second entry (checked) in the calendar view (on the same date with the other saved entry not checked) and try and save it it won't allow it, the condition then fires correctly!

It's working perfectly for the other combinations.

Any further thoughts would be appreciated?

Thanks

J


author: Alex Medved _ConfiForms_
body: Hi

And this is exactly how it is designed and works (this is how I understood your earlier requirements)

So, what exactly is your requirement?

Alex


author: JN
body: At the point where the user saves an entry(with the ChangeControl checked) on a date where there is already an entry without the ChangeControl Checked is the scenario where the above function isn't seeing that the date is not empty.

I only want it to allow 1 entry per day if the Change Control is checked, if an entry already exists (regardless of the checked box) then it mustn't allow it.


author: Alex Medved _ConfiForms_
body: I dont understand to be honest.. How many records do you want to accept (per day) when the checkbox field is unchecked?


author: JN
body: up to 2 unchecked

only 1 if checked


author: Alex Medved _ConfiForms_
body: I suggest to learn a bit how the filters work and what you can do - <https://wiki.vertuna.com/display/CONFIFORMS/ConfiForms+Filters>

I believe this filtering expression should do the trick

```
(Date:[entry.Date] AND ChangeControl:true AND !id:[empty] AND _count:>=1) OR (Date:[entry.Date] AND ChangeControl:false AND _count:>2) OR (Date:[entry.Date] AND _count:>2)
```

Alex


author: JN
body: Hi Alex,

Thanks again but it's still not working, it's like it's not seeing that an entry is already there and it allows the 2nd entry to be added with the check box even though the filter suggests it shouldn't be more than or equal to 1 if checkbox is true!

not to worry I'll play with it and see if I can get it working.

Appreciate all the help.


author: Alex Medved _ConfiForms_
body: When exactly it does not work?

Here is how I test <http://recordit.co/gnvCCsmszg>


author: JN
body: delete the 2nd entry for the 2nd Aug and try adding a new entry with the checkbox ticked for the 2nd Aug.

It's shouldn't allow it because it should only allow 1 entry with a check box per day


author: Alex Medved _ConfiForms_
body: ```
(Date:[entry.Date] AND ChangeControl:true AND !id:[empty] AND _count:>=1) OR (Date:[entry.Date] AND ChangeControl:false AND _count:>2) OR (Date:[entry.Date] AND _count:>2) OR ((Date:[entry.Date] AND _count:>1) AND (ChangeControl:true AND _count:>0))
```


author: JN
body: That works perfectly - appreciate all the assistance. That really helps to also understand the complexity of how the filters work

Thanks again!

J


author: Alex Medved _ConfiForms_
body: The complexity here brings the fact that you want to filter against the existing dataset and check for (different) counts under different conditions.

Usually the filters are much simpler :-)


author: JN
body: That's where I was struggling - I tried a few combinations with a _count:\>0 but didn't have the syntax correct.

it's been a great learning opportunity


Tags: confiforms

confluence-server

server