Hi,
If you need to define a uniqueness check for one (or more) "primary key" attribute, just define it as Key.
If you already defined an attribute as the (primary) key attribute and you want to check the uniqueness of another attribute, you can create a new Uniqueness check for that attribute and write an expression that will return the list of values that must be unique (e.g. suppose that you want to assign a tree_name
to every tree and this name must be unique, you can define a Uniqueness check with an expression like: parent()/tree/tree_name
. The check will verify that the value you insert in tree_name
is unique considering all the tree entities.
If you want to check the uniqueness of more than one attribute, for example attribute1
and attribute2
you cannot use the Uniqueness check (nowadays...) but you have to define a Custom check using an expression like this:
count(parent()/tree[attribute1 = $this/parent()/attribute1 and attribute2 = $this/parent()/attribute2]) = 1
This expression looks a bit tricky but it's just saying that the number of trees having attribute1 and attribute2 equal to the current
one must be equal to 1.
Thanks a lot,
Open Foris Team
answered
22 Apr '16, 15:59
Stefano (OF) ♦♦
4.9k●1●1●9
accept rate:
19%