Check for Duplicate fields of An Entity?

0
I have an Entity in which all the fileds(attributes ) are filled and stored in a datagrid. When I try to enter a new Record, it Should check all the fields for Duplicacy from Existing Rows. Can we implement this feature in Mendix.
asked
3 answers
1

To expand on Stephan's answer: create a custom microflow for your save action. In this microflow, you can retrieve an object which has duplicate attributes (using the retrieve action). The XPath constraint would look like:

[id != $ObjectYouWantToCommit] 
[Attribute1 = $ObjectYouWantToCommit/Attribute1]
[Attribute2 = $ObjectYouWantToCommit/Attribute2]

If you retrieve such an object, you know you should not commit the current object to the database, because it is a duplicate. You can then give feedback to the user about what is wrong. If you find no such object, you can then commit the current object to the database.

answered
1

Mendix has a Unique constraint you can add to the Attribute of the Entity in your Domain Model.

Go to Domain Model -> Open Entity -> Validation Rules tab -> Click New -> Select Attribute -> Select the Unique radio button.

If you want to do this on multiple fields, I would suggest maybe a checksum (http://en.wikipedia.org/wiki/Checksum) field with this validation.

answered
0

This can be done by creating your own microflow or java action.

answered