Validation rule with [%CurrentDateTime%]

0
I created a validation rule for a date field. The date should be greater or equal to current date ([%CurrentDateTime%]). The language of the project is Dutch. So the date picker displays on the dataview the date with a date format like dd-mm-ccyy. When I tried to save the data, I get next error message on the modeller console: “com.mendix.core.CoreException: Exception occurred in action '[ChangeAction:: Context:Context::[Session [d899dc5e-30ae-4a99-9bed-40ce79478e13]], Changes:{Accountmanager=manager1, Vervolgdatum=1305842400000, Acties=test, TypeActie=Vervolg, Afgehandeld=Nee}', all database changes executed by this action were rolled back at com.mendix.core.actionmanagement.CoreAction.d(SourceFile:553) Caused by: java.lang.IllegalArgumentException: Invalid format: "CurrentDate" at org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:683) at cQ.a(SourceFile:295) at cQ.a(SourceFile:288) at fG.b(SourceFile:431) at fG.a(SourceFile:173) at lg.setValue(SourceFile:236) at com.mendix.core.objectmanagement.member.MendixDateTime.parseValueFromString(SourceFile:55) at aQ.setValue(SourceFile:274) ” Further I changed the value of the validation rule with a hard-coded date in “ccyy-mm-dd” format. Then I get expected error message or validating. How can I create the validation rule with value “>= Current Date”
asked
1 answers
2

You could do the validation in a microflow. In this case you'd put it in the microflow which is executed when you click on the form's 'Save' button, or replace the Save button with a custom microflow.

In this microflow, you could check the condition using an exclusive split, and if the check fails, display validation feedback on the date and end the microflow without committing the object. If the check comes out ok, the flow should then commit the object and close the form, as well as any other actions which are supposed to happen in this flow.

If there's multiple rules you want to check in one go, you could have the 'failed' path for a check display validation error, set a boolean 'ValidationErrors' to true and merge with the 'true' path, doing this for several checks and eventually checking 'ValidationErrors' to see if the microflow should end or if the commit/actions should be executed.

Usually Before Commit microflows can be suitable to check for validation conditions which should always be true. However I do not quite know your exact scenario, and validating with [%CurrentDateTime%] (which changes constantly) in a Before Commit might be risky if you decide to edit the object again later on. (Since the date picked earlier might well be valid, but would fail the [%CurrentDateTime%] check)

answered