Select to view content in your preferred language

Attribute rule - Unexpected null error in Pro 3.1.3

543
3
11-06-2023 10:00 AM
CaseyJ
by
Emerging Contributor

Hello, I have an attribute rule that previously worked in Pro 2.7, but hasn't worked since updating to Pro 3+, I'm currently operating Pro 3.1.3. Below is the current version of the script after some troubleshooting, I'll be happy to post the original code that worked in 2.7 if that would be helpful. 

Workflow: 1) EsmtPoly is created and manually split by other unrelated attributes; 2) EsmtPoly is split by the gSSURGO_2022polys_XYZ feature class

Attribute rule intent: If the EsmtPoly features overlap multiple gSSURGO polys, the result should be "Split req'd," but after splitting by gSSURGO polys, there should be exactly 1 match for the Within function, and therefore the result should be the MUSYM from the gSSURGO polys. 

 

//check if the geometry has changed or not, if it didn't simply return
if ( Equals(Geometry($feature), Geometry($originalFeature))) return 

var soils = featuresetbyname($datastore, "gSSURGO_2022polys_XYZ", ["MUSYM"], true)
var EsmtPoly = geometry($feature)
var sMatch = Within(EsmtPoly, soils)
var sCount = count(sMatch)

if (sCount != 1) {return "Split Req'd"
    } else { 
    if (sCount == 1) {   
       var sType = first(sMatch)
       return sType.MUSYM }}

 

I have been attempting to troubleshoot the script, and I've managed to get it to work so long as the result is the return "Split req'd" (which is an improvement). However, when I split by the gSSURGO polys, I receive this error (yes, the split properly intersects in two or more places):

Split failed. Geometry must intersect polylines and polygons in two or more places.
Failed to evaluate Arcade expression. [
Rule name: MUSYM within,
Triggering event: Insert,
Class name: EsmtArea,
GlobalID: {CA601BD9-DC07-42DC-8713-AD30C9E59FED},
Arcade error: Unexpected null,
Script line: 13]

3 Replies
CaseyJ
by
Emerging Contributor

ETA: I'm still very new to Arcade and Attribute Rules, self-teaching based on all of the helpful posts in this community and other forums/blogs. If anyone has a better approach they would use, I'm open to suggestions! Below is the rule that originally worked in 2.7, for reference. Thanks!

//check if the geometry has changed or not, if it didn't simply return
if ( Equals(Geometry($feature), Geometry($originalFeature))) return 

var soils = featuresetbyname($datastore, "gSSURGO_2022polys", ["MUSYM"])
var EsmtPoly = geometry($feature)
var sMatch = Within(EsmtPoly, soils)
var sCount = count(sMatch)

if (sCount != 1) return "Split Req'd"
       
var sType = first(sMatch)
iif (sCount == 1, sType.MUSYM, "ERROR")
0 Kudos
Nicorocas
New Contributor
Hi Casey
I am facing the same problem as you. I have an arcade that previously worked in Pro 2.6-2.9 but now in 3.1 it stops with the same Unexpected Null error,
I am trying to avoid null value by filtering the layer with Filter(feature, 'value is NOT NULL'); is not working though

 

 

var newDeviceGeom = $feature
var featurePoints = FeatureSetByName($datastore, "WaterLine", ['tipored'], true)
var featurePoint = Filter(featurePoints, 'tipored is NOT NULL');
var selectedFeatureSet = Intersects(featurePoint, newDeviceGeom);
if (count(selectedFeatureSet) > 0) {
   var thePoint = First(selectedFeatureSet);
   return thePoint.tipored

}else return $feature.tipored

 

 

 

0 Kudos
CaseyJ
by
Emerging Contributor

I never did find a solution using attribute rules, so I ended up changing my workflow entirely. Sorry, I hope you are able to find a solution that works for you! 

0 Kudos