Hi all,
I posted a few days ago about an issue I was having with related records in an arcade expression not evaluating correctly. I came to find out that the globalID (which I always use as my primary key) was not populating until after the submission of a feature, therefore affecting my sql statement to look into the related records. To fix this, I created a new primary key field and used that for my relationships. I then added this code:
var AllLeaks = FeatureSetByName($map,"Gas Leak")
var LeakCount = Count(AllLeaks);
var NewestLeak = First(OrderBy(AllLeaks,"LeakID DESC"));
if(LeakCount == 0){
return 1
} else {
return sum(NewestLeak.LeakID, 1);
}
... to make my own auto-incrementing key. The problem with this is, that if I have to go back into an already-submitted feature to edit something, it renumbers this LeakID, and the relationships are gone. Is there a way with Arcade that I can tell it to only evaluate this code on the creation of a new feature and not when updating it? or is there a better way of doing what I'm doing? I also tried to have it do a compare of the object ID of this feature to the newest feature to stop it from updating, but that doesn't seem to work. I would like to keep the end users from having to enter their own leak number if possible.
Thanks,
Damon