Hello
I have the following Arcade code to create a new Unique ID on a feature layer (hosted on ArcGIS Server). It's working fine for a NEW record, but if I try to select an existing record, it will update the UID field with the next available number.
How can I avoid to overwrite an existing value? Thanks for any help you could provide.
D
var fs=FeatureSetByName($datastore,'dr_testPts',['FUID'],false);
var cCurrentFUID = $feature.FUID
var fFilter = Filter(fs, 'FUID IS NOT NULL');
var fMax = 0
var tMax = 0
for (var k in fFilter){
fMax = Max(Right(k.FUID, Count(k.FUID)-3))
tMax = When(fMax>tMax,fMax, tMax)
}
tMax +=1
var vNewFUID = "EOC" + text(tMax, "00000")
if (IsEmpty(cCurrentFUID)){
return vNewFUID
} else {
return cCurrentFUID
}