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.
@GeeteshSingh07 Thanks for the reply.
The 'Nummer' field does not have a default value and it's set to not nullable, so that's why the value is 0 and not null.
I've also tried to use the fully qualified name of the sequence like so:
if (IsEmpty($feature.BusinessKey) || $feature.BusinessKey == 0) {
return NextSequenceValue("Gismo.S_STOPPOINT_BUSINESSKEY")
}
return $feature.BusinessKey
But with same result.
@CarstenAndersson , also did you test with schema owner of the database sequence?
@GeeteshSingh07 Yes. Gismo is the schema owner
@CarstenAndersson even after refreshing the layer or reopening ArcGIS Pro, it appears 0?
What if we restart the service, does it still appear 0?
If yes, then, there is a mismatch between Oracle table and EGDB, which is weird, and it shouldn't happen.
@GeeteshSingh7 The 'Nummer' field is actually set in the database (SQL Server, not Oracle). So, when I save and restart ArcGIS Pro I can see the value. But, I need to see it immediately.