I'm trying to make a complex data validation that requires to call a web service and also check if that result is in the database (Some kind of duplicate object validation). Is there any way to do that kind of validation in the Constraints of the Contract? Basically I need to add Groovy code as a constraint of the Contract. Is that posible? I'm using Bonita 7.5.1
Thanks in advance.
Validations defined in the contract are attend to be used only to validated contract inputs by doing some coherency tests between all the provided inputs or by doing some comparison with the business variables, not by calling an external system.
As you want to do some complex validations I would recommend to handle that in one or several service tasks in the process and use some connectors to perform web service and database calls.
Also note that this would be server side validation. If you want to do some validation directly in the form I would recommend to create a REST API extension to handle the validation and have your form call the REST API extension.
Hi Antoine, thank you very much for your answer.
The problem is that I need to make that validation in the form that instantiates the process and I don´t want to start a case if the validation fails. I can avoid calling the webservice, forget about it, but I need to access the business data to check if the record that I'm going to create already exists in the model.
I just realized that I can call a Groovy Script in the Constraint, but the apiAccessor isn't accessible. Is it possible to access the business variables at that point?
This is exactly what is happening to me now: https://community.bonitasoft.com/questions-and-answers/access-dao-object...
I think that I will try to make all the validations in the front end as you suggested to edo_2 . Please let me now if there is a better approach to do this.
Thank you very much.