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:
Thank you in advance for your help! I’m happy to provide more details if needed. 😊
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
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]):<-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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, so there is no datetimeinterval field... and the validation needs to be implemented with a ConfiForms Field Definition Rule
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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]):<-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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Should that line be in the condition part or below in the validation rule?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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]):<-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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is a correct condition
start.workDaysTo([entry._now]):<10
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If I use that one, it triggers the validation from any date I pick. Even if it is a month in advance:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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]):<-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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.