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
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.
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?
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.
Bonitasoft empowers development teams with Bonita, the open-source and extensible platform to solve the most demanding process automation use cases. The Bonita platform accelerates delivery of complex applications with clear separation between capabilities for visual programming and for coding. Bonita integrates with existing solutions, orchestrates heterogeneous systems, and provides deep visibility into processes across the organization.