Select to view content in your preferred language

Arcade in map viewer error - unique ID

474
2
02-16-2024 12:59 PM
Laura
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',
['TREEID'],
false
);
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
Omar_A
by Esri Contributor
Esri Contributor

Hi,

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.

Amir-Sarrafzadeh-Arasi
Frequent 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