I have Solved: Attribute Rule Expressions: calculate max value fr... - Esri Community successfully working in the fgdb environment. What I'm looking to do is replicate in a "new" web map viewer "Form" to autopopulate an unique ID field that IS NOT the objectID nor the GlobalID. Thing is, the data contains many existing records, with this ID ranging from 1-15000, with many values in between missing due to past deletions. What I want is to look at the max value in this field, and have (Arcade?) auto populate the next highest value when the user creates a new point, based on this form. But I don't see how this is possible as AGOL (still!) does not support GDB attribute rules and Create Database Sequence (Data Management)—ArcGIS Pro | Documentation
Solved! Go to Solution.
This seems to work in New map viewer and in Field Maps if I set up calculation on the field in the Form.
var vals = FeatureSetByName($datastore,"Sign",['TestInt'],false)
var numarray = []
for (var n in vals){
var nn = Number(n.TestInt)
Push(numarray, nn)
}
var maxnum = Max(numarray)
var newnum = maxnum + 1
return newnum
Depending on how many records, it takes a bit to respond. Could be a 'faster' way, but I'm not familiar enough with Arcade to figure out how to speed it up.
R_
This seems to work in New map viewer and in Field Maps if I set up calculation on the field in the Form.
var vals = FeatureSetByName($datastore,"Sign",['TestInt'],false)
var numarray = []
for (var n in vals){
var nn = Number(n.TestInt)
Push(numarray, nn)
}
var maxnum = Max(numarray)
var newnum = maxnum + 1
return newnum
Depending on how many records, it takes a bit to respond. Could be a 'faster' way, but I'm not familiar enough with Arcade to figure out how to speed it up.
R_
And for future folks with this question, this is what worked for my case with actual FC and field name, performance is fine with 2k records.
var vals = FeatureSetByName($datastore,"COR_HYDROPOWER_PROJECT_POINTS",['HYDRO_PROJECT_ID'],false)
var numarray = []
for (var n in vals){
var nn = Number(n.HYDRO_PROJECT_ID)
Push(numarray, nn)
}
var maxnum = Max(numarray)
var newnum = maxnum + 1
return newnum