---
title: "How do I create an autoincremented index number in the root?"
url: "https://openforis.support/questions/2030/how-do-i-create-an-autoincremented-index-number-in-the-root"
tags: ["calc"]
status: "answered"
score: 0
answer_count: 2
asked: "2018-11-29T04:59:54"
last_activity: "2018-12-01T05:43:32"
source: "Open Foris Support - Q&A Forum"
license: "Copyright Open Foris, 2026. Some rights reserved under creative commons license."
---

# How do I create an autoincremented index number in the root?

Asked by bsenterre on 2018-11-29

Dear all,
I would like an attribute "id" in the root of my survey where the value is set to the last entered value + 1.
In a non-root entity, I can do that using math:parent()/tree/id + 1
But in the root I cannot make reference to parent()/ and therefore I cannot make this work.
Any help will be very much appreciated.
Bruno


## Answer (score 0, by collectearth on 2018-11-29)

Link: https://openforis.support/questions/2030/how-do-i-create-an-autoincremented-index-number-in-the-root/2031

Please [see the answer to this other question][1] and get back to us if it doesn't fix your issue.


  [1]: http://www.openforis.org/support/questions/856/collect-how-to-set-auto-increment-on-key/857


## Answer (score 0, by bsenterre on 2018-12-01)

Link: https://openforis.support/questions/2030/how-do-i-create-an-autoincremented-index-number-in-the-root/2042

Thank you for this! I understand but I would still see some clear interest in having the option of an auto-incremented attribute. It would be unique if if simply I add an attribute with a short alphanumeric code identifyng the device used.
Therefore I could have my entries labelled more easily S40-156, S40-157, etc. (in place of the concatenation I have to do now without auto numbered index: S40-20181128-1632, using device+date+time).
I also have the issue with a child entity: e.g. I have 'specimens' as a child entity to 'plot', 'plot' being child to 'exploration event'. In 'specimen' I have to use a continued numbering and I would like the system to search for the maximum value entered in all specimens of all plots and all exploration events.
Thanks a lot for your help.
