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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.