Help with Arcade For Loops and editing related features

62
1
Jump to solution
a month ago
ajevans429
New Contributor

I'm super new to using for loops in arcade, and I'm trying to construct an Attribute Expression on the shape field which triggers an update to the geometry of all related records, triggered by an update to the parent feature. Related (child) fc is called 'gistree.gisowner.Forestry_Tree_Work'.

After making this active, I get an error when trying to submit an update to a parent feature with related records. If the parent feature does not have any related records (count is 0), then it submits fine, as it should.

Could anyone help me out with my error?

var fstreework = FeatureSetByName($datastore, 'gistree.gisowner.Forestry_Tree_Work')
var treeglobalid = $feature.globalid
var sql = "relglobalid = '" + treeglobalid + "'"
var fsListRelated = Filter(fstreework, sql)
var WorkList = []
var counter = 0
var noWork = Count(fsListRelated)
if (noWork > 0) {
for (var work in fsListRelated) {
WorkList[counter] = {
'globalid': work.globalid,
'attributes': {
'geometry': Geometry($feature)
}
}
counter++
}
return {
'result': Geometry($feature),
'edit': [{
'className': 'gistree.gisowner.Forestry_Tree_Work',
'updates': WorkList
}]
}
} else {
return Geometry($feature)
}

0 Kudos
1 Solution

Accepted Solutions
ajevans429
New Contributor

Solved! For anyone who may stumble upon this post, my error was in that I was trying to modify related geometry (shape field) by using the field name 'geometry' instead of 'shape'. Made the change and it works perfectly!

View solution in original post

1 Reply
ajevans429
New Contributor

Solved! For anyone who may stumble upon this post, my error was in that I was trying to modify related geometry (shape field) by using the field name 'geometry' instead of 'shape'. Made the change and it works perfectly!

View solution in original post