I'm working with a feature class within an Enterprise GeoDB in ArcGIS Pro. I have a field called "Unique_ID" that I want to attach an attribute rule to.
Here's the rule: whenever a new feature is inserted, I want this field to calculate the maximum value from a field called "ORIG_ID" values in the same layer, add 1 to it, and update "Unique_ID" with this number.
I have a rule within Expression Builder with the following Arcade expression. This max method being used is more or less, the same example given here: Mathematical Functions | ArcGIS for Developers under Max.
<SPAN class="keyword token">var</SPAN> competitors <SPAN class="operator token">=</SPAN> <SPAN class="token function">FeatureSetByName</SPAN><SPAN class="punctuation token">(</SPAN>$datastore<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"route.to.FeatureClass"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> uuid <SPAN class="operator token">=</SPAN> <SPAN class="token function">Number</SPAN><SPAN class="punctuation token">(</SPAN>$feature<SPAN class="punctuation token">.</SPAN>ORIG_ID<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="token function">Max</SPAN><SPAN class="punctuation token">(</SPAN>competitors<SPAN class="punctuation token">,</SPAN>uuid<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="number token">1</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
The expression is validated correctly. I set the triggers to be Insert and Update and save the process. But when I try to add a new row to the attribute table or create a feature on the map, the Unique_ID field is populated with the ORIG_ID value for that row + 1. Essentially, the maximum value of the entire field is not calculated.
Any ideas on how to solve this? Thanks.