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 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 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 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 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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events