validation error

0
I have an entity 'Rental' with two date attributes: startDate and endDate. When I make a validation rule: endDate >= startDate and I create an instance of the entity I got an error message: Failed to set autonumber and/or tokens for object 'Rental'. What does this mean and how can I solve this problem?
asked
3 answers
3

Did you set [%CurrentDateTime%] as the default value for endDate and no default value for startDate by any chance? If so, this would explain the error: when the object is created Mendix tries to set the default value for endDate, but this fails because it doesn't comply to your validation rule (a date value is never greater or equal to an empty value).

IMO, validation rules should only be checked on a commit, but currently they are also checked when changing an object (including when Mendix tries to set default values for attributes). To solve the error, you could either validate using a before commit microflow instead of validation rules on the entity, or remove the default values for the attributes on the entity.

answered
0

Problably you are setting an autonumber attribute.

answered
0

Alexander, Chris, thanks. I set [%CurrentDateTime%] for both endDate and startDate. I have no autonumber attribute. It is not the behaviour expected.

answered