How to validate attibutes calculated from expression?

  • Asked
  • Active
  • Viewed 6380 times
0

OF Collect version 3.9.13:
I created a new unique ID calculated from an expression from the attribute tree ID and stem ID and I'd like to use the new calculated ID for checking the uniqueness during data entry.
The options "Is key?" and "Strict" in Survey Designer are disabled for calculated attributes. How can I prevent duplicates during data entry and cleansing? Kind regards.

0

Accepted answer

Hi,
Nowadays you cannot define a calculated attribute as identifier of an entity.

You can define both tree_id and stem_id as the key identifiers for the tree entity.

Please try it and let us know.
Thanks,
Open Foris Team

0

Accepted answer

Dear ricci and Open Foris Team,
the first solution was already smart but this one is very elegant and works perfectly. Grazie mille!

0

Accepted answer

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

Your answer

Markdown text. Shortcuts: Ctrl+B bold, Ctrl+I italic, Ctrl+K link, Ctrl+E code, Ctrl+Shift+V paste as plain text. Tab indents list items and code; press Escape, then Tab, to leave the text box.

Insert an image

Say what the image shows, for people who can't see it.

Keyboard shortcuts

Anywhere

?
Show this list
/
Search
g h
Go to the home page
g q
Go to the questions
g t
Go to the tags
g u
Go to the users
a
Ask a question

Lists of questions

j k
Next or previous question
Enter
Open the question

Question pages

j k
Next or previous post

Shortcuts never apply while you type in a text field. Members can turn them off in their preferences.