Dynamic Constraint Message (Logic expression)

per Redirecting to https://getodk.github.io/xforms-spec/

jr:constraintMsg Specifies the custom message to be displayed when the constraint is violated. Value can be string literal ( jr:requiredMsg="message" ) or a translation function call ( jr:requiredMsg="jr:itext('id')" ).

[BTW typo noted…]

Which is to say, the contents of the constraint_message column in an XLSForm are interpreted as either a literal string, or at most a jr:itext() translation. Whereas relevant, required, read_only, constraint, calculation may contain an XPath (aka logic) expression and will be evaluated as such, both requiredMsg and constraintMsg are not evaluated as expressions.

The only way to present different constraint messages is to have them associated with different constraints on different questions, and control the display of said questions using relevance.

1 Like