Arcade in map viewer error - unique ID

02-16-2024 12:59 PM
by MVP Regular Contributor
MVP Regular Contributor

I am trying to create arcade for my TREE ID. I have some IDs currently, but would like it to auto calculate a new ID that comes next in line when another record is creating. My code does not have an output. Any ideas?

var fset = FeatureSetByName($map,
'Tree Inventory',
var fset_sorted = OrderBy(fset, 'TREEID DESC');
var firstRow = First(fset_sorted);
var highestID = firstRow.TREEID;
var newID = highestID + 1;

if($originalFeature{'TREEID'} > 0){
  return $originalFeature{'TREEID'}
} else {
  return newID
This arcade is copied from a CloudPoint Geospatial video. 
0 Kudos
2 Replies
by Esri Contributor
Esri Contributor


Ensure your FeatureSetByName function call is syntactically correct. You are missing a comma before the false
parameter. Also, It's good practice to include some form of error handling or checking to ensure that your script can handle unexpected situations , such as when there are no features in the feature set.

Occasional Contributor

Dear Laura,

I think if you want to access a field of a Feature you should use one of these ways:

1) $Feature.fieldname

2) $Feature['fieldname']

and I am not surehere you can use $originalFeature.


Amir Sarrafzadeh Arasi
0 Kudos