Select to view content in your preferred language

Calculating Unique IDs in fieldmaps

129
1
02-12-2025 08:19 AM
amandakwong
New Contributor

Hey everyone! I am trying to calculate a unique id for every test my field staff do out in the field. As we will have multiple crews in the field working offline I wanted to add the supervisors initials to it  to keep the records unique.  For some reason my code starts at 1-xy but then when  put the next point down it jumps to 12-xy, and then every point after that remains at 12-xy for every point afterwards. If anyone has some insight into why its not calculating properly I would really appreciate it. 

This is the code I have that is not calculating properly :

var numberlist = FeatureSetByName($map, "Subsurface Inspections")
var topnum = Top(OrderBy(numberlist,'OBJECTID'),1)
var counter = Number(Max(topnum,'OBJECTID'))
var id = counter + 1
var sup = $feature.Supervisor
return id + '-' + sup
 
Thanks!
0 Kudos
1 Reply
DougBrowning
MVP Esteemed Contributor

Looks like topnumber you are not sorting in descending order with OrderBy

See here  https://developers.arcgis.com/arcade/function-reference/featureset_functions/#orderby 

in counter you are taking the max so I do not think you even need orderby really.  But then you are adding onto objectid and not the actual count of records.  This may be ok though since it would cover you on deletes.
this may work
var counter = Number(Max(numberlist,'OBJECTID'))

Also if the user does not take all the records offline this could fail on you.  Overall we just gave up on numbering as we do not really need it anymore.

0 Kudos