Select to view content in your preferred language

Attribute Rules Error When Inserting New Row

569
3
08-29-2022 02:31 AM
MatsHardy
Regular Contributor

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?

3 Replies
JohannesLindner
MVP Frequent Contributor

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!


Have a great day!
Johannes
0 Kudos
MatsHardy
Regular Contributor

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?

0 Kudos
JohannesLindner
MVP Frequent Contributor

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:

  • change the Attribute Rule, using the expression I posted above
  • change your script, so that it inserts valid points

 

To get more meaningful help, you would have to post your script.

JohannesLindner_0-1662363141093.pngJohannesLindner_1-1662363160899.png

 


Have a great day!
Johannes
0 Kudos