I am writing a script to create a junction point in a utility network with attribute rules. But when I ran the execute, the following error is shown:
Traceback (most recent call last):
File "CreatePolygonCentroid.py", line 76, in <module>
junCur.insertRow(insRow)
RuntimeError: Arcade script raised an error. [
Rule name: Division,
Triggering event: Insert,
Class name: StormwaterJunction,
GlobalID: {48BEB490-EF59-4756-818A-BDB41DD071E0},
Script error: result = null]
And below is the "Division" rule:
var featureSet = FeatureSetByName($datastore,'B_DSD_District', ['DIV'], true);
var featureSet2 = Intersects(featureSet, Geometry($feature))
var result = First(featureSet2)
if(result==null)
return {"errorMessage": "result = null"}
else
return result.DIV
How can I create the junction by script without disabling the attribute rules?
According to the error message, your new point doesn't intersect any features in "B_DSD_District". So you should probably take a look at your Python script and correct that.
Alternatively, you can change the Attribute rule, so that it doesn't return an error when that happens:
var featureSet = FeatureSetByName($datastore,'B_DSD_District', ['DIV'], true);
var featureSet2 = Intersects(featureSet, Geometry($feature))
var result = First(featureSet2)
if(result==null)
return null // return no value instead of an error
else
return result.DIV
This might break some of your workflows if it is important that this field is filled!
Thanks for your help, I have checked the file gdb, the feature class B_DSD_District exists in the gdb. Besides, the junction point should intersect with one of the polygons in B_DSD_District. How can I resolve the problem?
Besides, the junction point should intersect with one of the polygons in B_DSD_District
Well, the Attribute Rule throws an error because the point does not intersect a polygon in the feature class.
So, you have two possibilities:
To get more meaningful help, you would have to post your script.