Confiforms field definition rules - condition date syntax
Asked by JN:

Hi Alex,

I have an existing filter in my confluence calendar that limits the number entries on any given day

What I'd like to do is allow an additional entry (go from 2 to 3) for a given month or period, say Mar and Apr (but only during this time) - how do I go about specifying that in the condition filter?

Thanks  
Jonathan


Answers:
author: Alex Medved _ConfiForms_
body: Hi

What filtering condition do you have at the moment?

Alex

comments: author: JN
body: Hi Alex,

It's a condition you helped me with previously:

```
(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))
```

J


author: Alex Medved _ConfiForms_
body: Cannot remember, sorry - too many conversations :-)

The idea would be to add use of formatDate with specific pattern from <https://wiki.vertuna.com/display/CONFIFORMS/Virtual+functions>

Basically checking the "month" in addition

```
Date.formatDate(M):3
```

(3 goes for March, 4 for April, according to docs)

Alex


author: JN
body: fantastic - thanks for that, i'll give it a go and let you know if I get it working


author: JN
body: sorry Alex I'm struggling here; I can't work out who to add the (

```
Date.formatDate(M):3
```

) so that it checks the month being selected is "3" and then allows 3 entries as opposed to 2.

Any help or examples would be appreciated

Thanks

Jonathan


author: Alex Medved _ConfiForms_
body: You add where you need to check that - I mean, you know the requirement better

I am not sure I remember you exact requirements.. but basically

```
(Date:[entry.Date] AND Date.formatDate(M):3 AND _count:>3) OR (Date:[entry.Date] AND !Date.formatDate(M):3 AND _count:>2)
```


author: JN
body: That looks great - do I add that as a new rules for field definition with its own condition filter or just append it onto the current filter?

Thanks again

Jonathan


author: JN
body: Thanks Alex, got it to work - it's a combination of editing the two different condition filters and adding the relevant values from your example above where necessary.

Appreciate the support as always.

J


author: Alex Medved _ConfiForms_
body: Sorry, I have not provided an exact filtering condition (lack of time) - but I am glad you have figured it out yourself.

I would also do it in a way that I have multiple validation rules that validate the record for certain conditions. Easier to understand and maintain later


author: JN
body: No problem at all - you provided enough information for me to work it out.

Have a good day.


author: JN
body: Hi Alex,

Could you help me with the syntax in this filter please. I want to extend the option to multiple months. The query that works for one month looks like this:

```
(Date:[entry.Date] AND Date.formatDate(M):3 AND _count:>3) OR (Date:[entry.Date] AND !Date.formatDate(M):3 AND _count:>2)
```

I tried creating a separate rule field definition for each month and specifying the relevant number (M):x but that doesn't work.

I also tried adding an additional

```
AND Date.formatDate(M):x ?
```

but I'm not sure I have the syntax correct so it's not working either.

Any help would be appreciated.

Thanks

Jonathan


author: Alex Medved _ConfiForms_
body: I came up with something like this

(to allow 3 records per day in March/April) and only 2 per day on other months

```
((Date.formatDate(M):3 OR Date.formatDate(M):4) AND (Date:[entry.Date] AND _count:>3)) OR (Date:[entry.Date] AND !Date.formatDate(M):3 AND !Date.formatDate(M):4 AND _count:>2)
```


author: JN
body: works perfectly - I was able to adapt the other rule definition to follow the same syntax too.

Thanks again

J


Tags: calendar

confiforms

date

field