Select to view content in your preferred language

Strange attribute rule behaviour

577
7
02-27-2025 02:33 AM
CarstenAndersson
Regular Contributor

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:

CarstenAndersson_0-1740651064304.png

The feature service looks like so:

CarstenAndersson_1-1740651095128.png

In this case the BusinessKey is not zero:

CarstenAndersson_2-1740652010612.png

And the feature service has these layers now:

CarstenAndersson_3-1740652310053.png

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 🙂

0 Kudos
7 Replies
CarstenAndersson
Regular Contributor

And as I mentioned, even though it sometimes looks like the BusinessKey is zero

CarstenAndersson_0-1740659515849.png

It's actually another value in the table in the SQL database

CarstenAndersson_1-1740659613172.png

0 Kudos
GeeteshSingh07
Frequent Contributor

@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.

BUG-000124487 for ArcGIS Pro

--
Best Regards,
Geetesh
geetesh486@gmail.com
0 Kudos
CarstenAndersson
Regular Contributor

@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.

0 Kudos
GeeteshSingh07
Frequent Contributor

@CarstenAndersson , also did you test with schema owner of the database sequence?

--
Best Regards,
Geetesh
geetesh486@gmail.com
0 Kudos
CarstenAndersson
Regular Contributor

@GeeteshSingh07 Yes. Gismo is the schema owner

0 Kudos
GeeteshSingh07
Frequent Contributor

@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.

 

--
Best Regards,
Geetesh
geetesh486@gmail.com
0 Kudos
CarstenAndersson
Regular Contributor

@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.

0 Kudos