Dear Emily,
thanks for reporting this. In the latest version we changed how this is evaluated in default value expressions, to keep expressions consistent: this now always refers to the current node. In a default value expression that is the attribute itself, as it already was in the other expressions. Before, in default values, this referred to the entity containing the attribute (the tree). An attribute that is not multiple is always at position 0 in its entity, so index(this) + 1 now gives 1 for every tree, which causes the duplicate key errors.
To get the previous behaviour, change the default value expression to index($context) + 1. $context is the entity containing the attribute (the tree).
When you publish the survey, Arena asks whether to update the values in existing records. If you accept, the keys filled by the default value are recalculated, which also fixes the records entered since the update. Keys you typed by hand are kept. Note that if trees were deleted in a record, the keys of the following trees are renumbered to close the gap (e.g. 1, 3 become 1, 2). If you'd rather leave existing values untouched, publish without updating them and fix the duplicate keys by hand.
For new surveys, or if you don't need to recalculate existing data, we recommend ticking Auto incremental on the key attribute (you first need to remove its default value). Arena then numbers new trees 1, 2, 3, … and avoids duplicates even after a tree is deleted. It never changes key values already entered.
Many thanks,
The Open Foris Arena team