I have a feature service that points to a feature class called StopPoints ("Stoppunkter" in Danish) in a SDE database (SQL Server). The feature class has an immediate attribute rule, that gets the next value from a database sequence and sets it to a field called BusinessKey ("Nummer" in Danish), if it isn't already set to a value.
The attribute rule looks like so:
if (IsEmpty($feature.BusinessKey) || $feature.BusinessKey == 0) {
return NextSequenceValue("S_STOPPOINT_BUSINESSKEY")
}
return $feature.BusinessKey
This rule is triggered by Insert. I have checked Exclude by application evaluation. Directly after I've created the feature I query the table using SQL Server Management Studio, and I can see that the newly created row has the BusinessKey set to the next sequence value.
But for some reason, sometimes the BusinessKey is zero in the attribute pane and other times it's the value from the sequence. It seems like the number of layers has something to do with it, but I don't understand why that should be the case.
In this example the BusinessKey (Nummer) is zero:
The feature service looks like so:
In this case the BusinessKey is not zero:
And the feature service has these layers now:
It is worth mentioning that the two layers I removed has no attribute rules, triggers or any kind of calculation.
I don't understand this, so any help is greatly appreciated 🙂
And as I mentioned, even though it sometimes looks like the BusinessKey is zero
It's actually another value in the table in the SQL database
@CarstenAndersson By any chance, does 'Nummer' field have any default value set in ArcGIS Pro?
If assigning sequence fails, it should have given <Null>; however, it is giving zero.
You can also check this out:
BUG-000124487: An immediate calculation rule calling a database sequence using the NextSequenceValue() function in ArcGIS Arcade only works for the schema owner of the database sequence and fails for other database users.