---
title: "default \"index(this) + 1\" giving error when previously okay"
url: "https://openforis.support/questions/4632/default-indexthis-1-giving-error-when-previously-okay"
tags: ["arena"]
status: "accepted"
score: 0
answer_count: 1
asked: "2026-12-02T22:45:09.565286"
last_activity: "2026-12-02T23:00:13.121964"
source: "Open Foris Support - Q&A Forum"
license: "Copyright Open Foris, 2026. Some rights reserved under creative commons license."
---

# default "index(this) + 1" giving error when previously okay

Asked by ebrodie on 2026-12-02

Good afternoon,

Several of my surveys utilize "index(this) + 1" as a default to create a key/uid for repeated values (i.e. trees, regeneration, etc.). Since the last update, I am getting "Duplicate entity key" errors and it looks like all uid values are being populated with "1". Any ideas why this might have changed and what to do to fix it? 

Thank you,
Emily


## Accepted answer (score 0, by Stefano (OF) on 2026-12-02)

Link: https://openforis.support/questions/4632/default-indexthis-1-giving-error-when-previously-okay/4633

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

> Wow, I love the new "auto incremental" box. Thanks so much for this quick response! (ebrodie)
