Primary key or non replicated values for field

07-26-2018 03:25 PM
New Contributor

Hi,  I am working on a Survey123 form that I created to collect information on trees within a plot.  For each plot I have created a repeat to enter tree data for data we collect on up to 23 trees within that plot.  One of the fields in the repeat is Tree Number, and each of those trees is given a number 1 through 23.  If we accidentally enter the same number twice (e.g., label 2 trees #20) we cannot distinguish between the two tree records for that plot.  After being unsuccessful in finding a way to make this field a primary key or find a calculation that would prevent replicated values in the Tree Number field I ended up using a cumbersome fix for last weeks field work.  What I ended up doing is adding a multi-select checklist so that the recorder could select the number of the tree under the plot information section, and then under the repeat for tree information the recorder would have to enter that same number into a text field.  So the data has to be entered twice.  (See example of form below)

This method works in a pinch but is not ideal.  Is there a solution to either:

1 . Make Tree Number a primary key. 

2.  Prevent replicate values in tree number.

3.  Use a calculation that references the Tree Number entered under the repeat to autoselect the same number in the multi-select  under the plot information.

In some ways it would be nice to have the ability to do either #1 or #2 and in addition still have the multi-select (but one that is autopopulated as you enter tree number data).  This would prevent accidentally entering the same number twice under Tree Number while allowing the recorder to follow which trees in the plot still need data collected from them. 

0 Kudos
1 Reply
Esri Frequent Contributor

Hi Karissa,

Currently there is no way to set a primary key on a field in a Survey123 due to the requirements of working with the field app both online and offline and syncing data back to a central feature service. Manually entered data can not be unique using just a single number if being collected on multiple devices. Not sure if you have already come across this blog, which goes into more detail about ways to overcome similar problems to what you are experiencing: 


0 Kudos