Display contract failed constraints

When a user submit a form with complex contract constraints and one of those contraint is not valid, we get a org.bonitasoft.engine.bpm.contract.ContractViolationException

The message associated with this exception is Exception while validating constraints and we also get an empty explanations array.

Is there a way to get the list of failed contraints? Also I believe the error message used to contain the error message associated with the failed constraint but my last tests (Bonita Community 7.3.3 and 7.2.3) does not show them.

Knowing the failed constraint is mandatory for complex form validation and good user experience.

Have a look at this HowTo for forms validation and display on the UI.

http://documentation.bonitasoft.com/?page=manage-control-in-forms

Works for us.

regards
Seán

PS: As this reply answers your question, please mark as resolved by ticking the tick mark on the left of this reply.

If you add a var, type string at UI Designer, for example: error, and drop a text-widget:

HIDE: error == null   and TEXT: <b>Error :</b> {{error.explanations | json}} , then, only the text for "explanation" at the CONSTRAINTS (Bonita Studio) ,  will be displayed, and the text:

"exception": "class org.bonitasoft.engine.bpm.contract.ContractViolationException", "message", will not displayed. 

 

 

This would work if the explanations array was not empty (referencing “Use contract response for server side validation” chapter)

{ "exception": "class org.bonitasoft.engine.bpm.contract.ContractViolationException", "message": "Exception while validating constraints", "explanations": [] } 

I will have to test on a 7.4

On 7.4.2 explanations array is still empty. Is this a limitation of the community edition?

After digging in community source code, if message is “Exception while validating constraints” it means you have an exception thrown by the constraint groovy code, not that the constraint return false.

After some debugging in the constraints code I get an explanation array which can be used to display appropriate error messages to the user. There is no limitation in the community edition on this subject.

That is excellent research @g. And well worth documenting for the future.

Many thanks