how to add validation constraints to input that must be unique

1
0
-1

hello,

i use bonitasoft community edition v 2022.2

I have an object in my bdm named "product" that have the attribute "name" I want to add constraint to this input that must be unique, Can someone help me with groovy expression:

- How to get the object "project" with the groovy expression and search in the attribute of this object if the input value already exists?

1 answer

1
+1
-1
This one is the BEST answer!

Hi,

You can't implement this constraint at contract level, but you can instead use a unique constraint on the Business Object:
In the BDM editor, you can navigate to the unique tab and select the name attribute for the Product object.

It will generate a query for this object that can used in a web page to validate that a given product does not already exist. ../API/bdm/businessData/com.company.model.Product?q=findByName&f=name={{product.name}}&p=0&c=1

The above query will return an empty array if the product does not exist.

If despite the UI validation, a contract is sent server side and the product name already exists, the task execution or process instantiation will fail due to the unique constraint in the BDM.

HTH
Romain

Notifications