Hi there,
Thought I had the incremental numbering working in field maps, until I started revisiting old data points and noticed the groupID changed from the old number to the new group ID in the sequence.
Background - we conduct aerial surveillance of feral animals, making counts of various groups of feral animals seen from the air. Each group is assigned a sequential number that starts from one from each new survey ID (ReviewedSurveyID). Generally, we don't switch survey IDs mid survey, but I've set the code to hopefully factor for that.
Problem - sequential numbering is working ok, except when I need to revisit the point to make an edit (for example, to provide sample details or update the count of animals seen) - I've noticed that each time I go back to the point to make a minor change or update, the group's ID will be changed. So for example, if I have a group of feral pigs with a count of 5 and a groupID of 40, if I were to make subsequent counts of other feral animals (groupIDs 41-43) and then return to group 40 to take some samples, when I go into group 40's point, it's ID changes from 40 to 44.
Is there a way to lock in the variable after it has been entered/calculated. Kind of like with Survey123 and the use of once()
I have tried to incorporate the feedback from this post but not having luck with landing this - Solved: arcade calculation - once() or only when null - Esri Community
Here is my Arcade script so far:
If (!IsEmpty($feature.Group_ID)){
//save a new Inspection Date
//works online and with offline maps, won't work with offline AGOL maps
//increment by 1 from highest number for only features within current year
var Activity_Code = $feature.ReviewedSurveyID
var numberlist = FeatureSetByName($map,"Groups")
var filteredActivity = Filter(numberlist, 'ReviewedSurveyID = @Activity_Code') var topnum = Top(OrderBy(filteredActivity,'Group_ID DESC'),1)
var counter = Number(Max(topnum,'Group_ID'))
var Groupid = counter+1
return Groupid
//Return topnum
}
Currently this script is still changing my GroupID when not null