How to define uniqueness on association

1
Hi! What is the best way to enforce uniqueness of entity objects based on the relation to other objects? In my example: Type(1) - (*)Status, meaning a Type can have one or more associated Statuses. I need to make sure that when the user saves a record in Status, that there isn't already a status with the particular name associated with the current selected Type. However, the user should not be prevented to create the same Status associated with one of the other Types as well (this implies that setting a unique validation on Status will not work).
asked
2 answers
3

You could check it using a microflow: before saving or on change (of the reference selector) - retrieve the statuses with the same name and check their associations to type - if one that is currently selected already exists use the validation feedback activity or show an error message otherwise save.

answered
1

Another way to do this would be to create an attribute of Type that is built up by an attribute of Status + an attribute of Type. This way you can specify uniqueness in even more detail, for example: if you have Project and File entities, you'd want a certain Project to have unique File version numbers, but other Files should be able to use the same version numbers. In that case: File.UniqueNumber = Project.Name + File.VersionNumber.

answered