Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Rule for Date Field (10 Business Days in the Future)

Enrico Mancuso
Contributor
January 13, 2025

Hi Community,

I am trying to set up a validation rule for a datetimeinterval field in ConfiForms. The goal is to ensure that users can only select a start date that is at least 10 business days in the future. However, I’m having trouble making this work as expected.

I’ve attempted to use a validation rule to enforce this, but the system either allows invalid dates or fails the validation entirely, even when the input is correct.

Here’s the situation:

  • I want to restrict the start date of the event to be at least 10 business days from the current date.
  • The formula I’ve tried for this doesn’t seem to account for business days properly or might not be supported in my ConfiForms instance.

My Questions:

  1. Is there a reliable way to create a validation rule for business days in ConfiForms?
  2. If business day calculations are not natively supported, is there a recommended workaround?
  3. What is the best approach to ensure users comply with this requirement?

Thank you in advance for your help! I’m happy to provide more details if needed. 😊

2 answers

1 vote
Alex Medved _ConfiForms_
Community Champion
January 13, 2025

Hi @Enrico Mancuso 

You can try to employ the workDaysTo function from ConfiForms https://wiki.vertuna.com/display/CONFIFORMS/Virtual+functions

and have a validation rule with a condition like this (assuming your datetimeinterval field is called dti)

dti.startDate.workDaysTo([entry._now]):<-10

Alex 

Enrico Mancuso
Contributor
January 13, 2025

Its not working: here my source

<p>
<ac:structured-macro ac:macro-id="292d2d52-695a-4e10-9385-c16f369bbc5f" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">start</ac:parameter>
<ac:parameter ac:name="fieldLabel">Beginn</ac:parameter>
<ac:parameter ac:name="values">30</ac:parameter>
<ac:parameter ac:name="extracontext">true</ac:parameter>
<ac:parameter ac:name="type">datetime</ac:parameter>
<ac:parameter ac:name="validation">start.workDaysTo([entry._now]):&lt;-10</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="ac2db946-ca67-4e19-a756-10a32a7403a6" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">end</ac:parameter>
<ac:parameter ac:name="fieldLabel">Ende</ac:parameter>
<ac:parameter ac:name="values">30</ac:parameter>
<ac:parameter ac:name="extracontext">true</ac:parameter>
<ac:parameter ac:name="type">datetime</ac:parameter>
</ac:structured-macro>
</p>

Alex Medved _ConfiForms_
Community Champion
January 13, 2025

Ok, so there is no datetimeinterval field... and the validation needs to be implemented with a ConfiForms Field Definition Rule

https://wiki.vertuna.com/display/CONFIFORMS/ConfiForms+Field+Definition+Rules#ConfiFormsFieldDefinitionRules-Validationrule

Enrico Mancuso
Contributor
January 14, 2025

Jetzt so: 
<p>
<ac:structured-macro ac:macro-id="541919e2-11ff-49fc-ae73-98966cb3122d" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">start</ac:parameter>
<ac:parameter ac:name="fieldLabel">Beginn</ac:parameter>
<ac:parameter ac:name="values">30</ac:parameter>
<ac:parameter ac:name="extracontext">true</ac:parameter>
<ac:parameter ac:name="type">datetime</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="ac2db946-ca67-4e19-a756-10a32a7403a6" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">end</ac:parameter>
<ac:parameter ac:name="fieldLabel">Ende</ac:parameter>
<ac:parameter ac:name="values">30</ac:parameter>
<ac:parameter ac:name="extracontext">true</ac:parameter>
<ac:parameter ac:name="type">datetime</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="11e3a8ed-e792-402d-b135-96f89d315e97" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">start.startDate.workDaysTo([entry._now]):&lt;-10</ac:parameter>
<ac:parameter ac:name="fieldName">Hold!</ac:parameter>
<ac:parameter ac:name="values">.</ac:parameter>
<ac:parameter ac:name="action">Validation rule</ac:parameter>
<ac:parameter ac:name="actionFieldName">start</ac:parameter>
</ac:structured-macro>
</p>

Alex Medved _ConfiForms_
Community Champion
January 14, 2025

As the field "start" is not a DateTimeInterval field it does not have a "startDate" property - see https://wiki.vertuna.com/display/CONFIFORMS/Accessing+field+values+and+properties

So the condition should be something like

start.workDaysTo([entry._now]):<-10

Also, there is no need to set the value for the "regular expression" parameter

Enrico Mancuso
Contributor
January 14, 2025

thanks it works

0 votes
Jonathan Saldarriag
Contributor
March 27, 2025

Hi Alex,

I found this post because I need the same thing but the form is a bit more complex and has more rules. I used the last expression but the entry gets created without an issue, but it should show the error message.

The condition we have is 

deadlineSubmission.workDaysTo([entry._now]):<-10 AND typeCustomer:existingCustomer AND typeAssessment:InfoSecReview

I could not write the source code because of max characters 

 

Jonathan Saldarriag
Contributor
March 27, 2025

Should that line be in the condition part or below in the validation rule?

Jonathan Saldarriag
Contributor
March 27, 2025

I just created a mini form with this. The form is letting me select any date:

 

<ac:structured-macro ac:macro-id="4055eed5-1451-435c-91c9-3c3ddf6244a5" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="formName">testdays</ac:parameter>
<ac:parameter ac:name="type">Embedded</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="5d01bff9-56d1-43e5-ab75-fd97956dd7d0" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">testdays</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="ec4abb99-53e5-43e5-9830-371fa16c4bce" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">start</ac:parameter>
<ac:parameter ac:name="fieldLabel">Beginn</ac:parameter>
<ac:parameter ac:name="values">30</ac:parameter>
<ac:parameter ac:name="extracontext">true</ac:parameter>
<ac:parameter ac:name="type">date</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="d3c03728-80ce-4cdc-9263-729981feb4d8" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">start.workDaysTo([entry._now]):&lt;-10</ac:parameter>
<ac:parameter ac:name="fieldName">Hold!</ac:parameter>
<ac:parameter ac:name="action">Validation rule</ac:parameter>
<ac:parameter ac:name="actionFieldName">start</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
<p>
<br/>
</p>
<p>
<br/>
</p>
<p>
<br/>
</p>
<p>
<br/>
</p>

Alex Medved _ConfiForms_
Community Champion
March 28, 2025

This is a correct condition

start.workDaysTo([entry._now]):<10

 

Jonathan Saldarriag
Contributor
March 28, 2025

If I use that one, it triggers the validation from any date I pick. Even if it is a month in advance:

Image 28.03.25 at 13.29.jpegImage 28.03.25 at 13.29.jpeg

Alex Medved _ConfiForms_
Community Champion
March 28, 2025

No it doesn’t. It will trigger as it says, for anything that is less than 10 days in the past and for the future (those are negative numbers in this case)

The easiest method to debug something like this https://wiki.vertuna.com/spaces/CONFIFORMS/pages/180945533/Using+PlainView+to+debug+ConfiForms+expressions+Velocity+templates+and+more

Jonathan Saldarriag
Contributor
March 28, 2025

Hi Alex, thanks for the reply, sorry I did not get that last message. When you mentioned it doesn't, is it affirming that it doesn't work or negating that I can enter any date.

For today at march 28, even if I enter 30 April I still get the error. That is more than 10 business days in the future. 

Could you please elaborate a bit more on the plainview link you mentioned? Do I write the condition on it and see how it behaves? Is the idea behind to do trial and error and when it works, just copy that condition into the macro of the rules?

Alex Medved _ConfiForms_
Community Champion
March 29, 2025

What it should validate? The expression I have validates that you are allowed to enter the date that is 10 before the today (and not in the future)

start.workDaysTo([entry._now]):<10

 In the PlainView, you can just put something like (removing the validations to get the data entered and submitted in the form)

[entry.start.workDaysTo([entry._now])]

 And this will show the result of the function right on the page

Jonathan Saldarriag
Contributor
March 31, 2025

Hi Alex,

Sorry if I did not explain myself properly. Right now, we have a big form with a lot of rules. Our customer wants exactly what the title of this discussion is. When a user selects certain options, a hidden field called deadline for submission appears, but they want to block the first 10 business days, this is to give enough time for processing, meaning the user cannot enter a day before the following 10 business days. For example today is March 31, counting 10 business days, the user should be able to select only from April 14 and onwards. 

I am attaching some pictures of the set up we have, but because you cannot see the text inside and I cannot attached the whole source code, below I am copying the source code of that portion only:

<p>
<ac:structured-macro ac:macro-id="feb78f3e-8725-4bde-b840-b3987ccea7e2" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">deadlineSubmission.workDaysTo([entry._now]):&lt;-10 AND typeCustomer:existingCustomer AND typeAssessment:InfoSecReview</ac:parameter>
<ac:parameter ac:name="fieldName">Existing clients or RFP should have a date block of 10 business days</ac:parameter>
<ac:parameter ac:name="action">Validation rule</ac:parameter>
<ac:parameter ac:name="actionFieldName">deadlineSubmission,typeCustomer,typeAssessment</ac:parameter>
<ac:parameter ac:name="withReverseRule">true</ac:parameter>
</ac:structured-macro>
</p>Image 31.03.25 at 13.14.jpegImage 31.03.25 at 13.14 (1).jpeg

Alex Medved _ConfiForms_
Community Champion
April 4, 2025

If you want to allow dates that are 10 working days or later then the condition needs ti be something like (in my earlier example)

start.workDaysTo([entry._now]):>-10

 

Like Jonathan Saldarriag likes this
ojorumianeke
October 1, 2025

Hey Alex, 

I'm working on something similar and would appreciate some support. 

I'm using ConfiForms Rules for field definition for the field name startDate. I only want to allow start date entries 3 working days or later so I used 

startDate.workDaysTo([entry._now]):>-3

but that allowed weekend entries, this is not a valid entry for my use case as I only want to allow Monday - Friday entries so I tried 

startDate.workDaysTo([entry._now],6,7):>-3

but now no entries are valid 

Alex Medved _ConfiForms_
Community Champion
October 1, 2025

Hi

The "workDaysTo" function does not by default include the Sat/Sun - see https://wiki.vertuna.com/spaces/CONFIFORMS/pages/2359385/Virtual+functions

The expression

startDate.workDaysTo([entry._now],6,7):>-3 

will tell that the Friday and Saturday are to be excluded (weekends), useful for Arabic countries

Alex 

San
November 7, 2025

Hi Alex, I tried using workDaysTo function but its not working. Even though I enter a date within or outside of the date range, am still getting the error message that I have added. My fieldname is ReqImplDateTime and Field Type is DateTime. I tried the below expression in the validation rules text box. Is this something to do with version of confiforms ?

ReqImplDateTime.workDaysTo([entry._now],6,7):>-3 

This is the documentation I got from my Organization but I don't see a way to solve it. 

https://wiki.vertuna.com/spaces/CONFIFORMS/pages/1212428/Documentation

image (6).png

image (5).png

Alex Medved _ConfiForms_
Community Champion
November 7, 2025

This needs to be put in the "condition" parameter, not in the "validation rules"

The "validation rules" parameter expects a regular expression... this has nothing to do with the check for "workingDays" and the use of this function

San
November 7, 2025

Thanks Alex for quick turn around. I have created one macro ‘ConfiForms Field Definition’ and "ConfiForms Rules for Field Definition" like this. But looks like its not working. Am not sure if I am missing something here.

image (7).pngimage (8).pngimage (9).pngimage (10).png

Alex Medved _ConfiForms_
Community Champion
November 10, 2025

What is not working for you?

When the validation should trigger according to your business logic?

San
November 10, 2025

My requirement is Users cannot the select the date within next 3 days and We want them to give us 3 days notice. So I created the two macros "ConfiForms Field Definition" and "ConfiForms Rules for Field Definition" like above and added the condition. So we want this logic to work when the Save button is clicked or the User enters the date. But when I tried to add the date even after 3+ days, am still getting the error like below. So the logic to pick the date isn't working.

image (11).png

Alex Medved _ConfiForms_
Community Champion
November 10, 2025

Hi

Specifically, tried to recreate your form's setup

<ac:structured-macro ac:name="confiform-entry-register" ac:schema-version="1" ac:macro-id="4055eed5-1451-435c-91c9-3c3ddf6244a5"><ac:parameter ac:name="formName">testdays</ac:parameter><ac:parameter ac:name="type">Embedded</ac:parameter><ac:rich-text-body><p><br /></p></ac:rich-text-body></ac:structured-macro><ac:structured-macro ac:name="confiform" ac:schema-version="1" ac:macro-id="5d01bff9-56d1-43e5-ab75-fd97956dd7d0"><ac:parameter ac:name="formName">testdays</ac:parameter><ac:rich-text-body><p><ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1" ac:macro-id="c4e5c6a2-bbd2-4fff-b172-977909458133"><ac:parameter ac:name="fieldName">ReqImplDateTime</ac:parameter><ac:parameter ac:name="fieldLabel">Beginn</ac:parameter><ac:parameter ac:name="values">Yes</ac:parameter><ac:parameter ac:name="extras">yyyy-MM-dd HH:mm</ac:parameter><ac:parameter ac:name="extracontext">true</ac:parameter><ac:parameter ac:name="type">datetime</ac:parameter></ac:structured-macro></p><p><ac:structured-macro ac:name="confiform-field-definition-rules" ac:schema-version="1" ac:macro-id="a2223cf9-161b-4faf-bd4f-6c3b29785c28"><ac:parameter ac:name="condition">ReqImplDateTime.workDaysTo([entry._now],6,7):&gt;-3</ac:parameter><ac:parameter ac:name="fieldName">ReqImplDateTime</ac:parameter><ac:parameter ac:name="action">Validation rule</ac:parameter><ac:parameter ac:name="actionFieldName">ReqImplDateTime</ac:parameter></ac:structured-macro></p></ac:rich-text-body></ac:structured-macro><p><br /></p><ac:structured-macro ac:name="confiform-plain" ac:schema-version="1" ac:macro-id="574be5d8-c0a2-47cb-9031-93423eaf89d3"><ac:parameter ac:name="formName">testdays</ac:parameter><ac:plain-text-body><![CDATA[[entry.ReqImplDateTime.formatDate()] [entry.ReqImplDateTime.workDaysTo([entry._now],6,7)] <br/>]]></ac:plain-text-body></ac:structured-macro><p><br /></p><p><br /></p><p><br /></p>

Alex 

San
November 11, 2025

I tried with your code. But still having an issue with the dates, could be some organization restriction's being applied here.image (12).pngimage (13).png

Alex Medved _ConfiForms_
Community Champion
November 11, 2025

What version of ConfiForms are you using?

San
November 11, 2025

ConfiForms (version: 3.17.7)

Alex Medved _ConfiForms_
Community Champion
November 11, 2025

Take a look please at the docs on this function https://wiki.vertuna.com/spaces/CONFIFORMS/pages/2359385/Virtual+functions and the version it is supported on

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events