Select to view content in your preferred language

Arcade expression returns [objectObject] when duplicated for feature service view

410
1
Jump to solution
10-10-2023 01:20 PM
SFM_TravisBott
Occasional Contributor III

I have a python script that creates several views of a layer, duplicates a template map and app, and then drops the new view into that map/app. Part of the equation is an Arcade expression in the template map. In the template map it works perfectly, taking the largest overlap of an underlying layer and applying it to a field. However, after the script creates a view, duplicates the map and app successfully and imports the form this expression returns [objectObject] instead of the appropriate overlap. The expression works appropriately when tested in Arcade editor, but not when actually editing the dataset. 

It should be noted that two other Arcade expressions are duplicated in this process and they both execute fine (calculating the 'County' and 'Acres' fields, see image below). It's only this 'largest overlap' calculation that fails upon duplication. 

The original Arcade the works in the template map:

 

//California Wldland Fire Direct Protection Areas is the layer extracted from. 
//The value of of the RESPOND_ID field is then applied to the DPA_AGENCY field in the target layer. 

var fsDPAIntersect = FeatureSetByName($map, "California Wildland Fire Direct Protection Areas", ["RESPOND_ID"])

var fsDPAIntersect = Intersects(fsDPAIntersect, $feature)
var intersected_DPAS = []
for(var j in fsDPAIntersect) {
    var respond_id = {
        RESPOND_ID: j.RESPOND_ID,
        Overlap: Area(Intersection(j, $feature))
    }
    Push(intersected_DPAS, respond_id)
}
function sort_by_overlap(j1, j2) { return j1.Overlap < j2.Overlap }

var respond_id = First(Sort(intersected_DPAS, sort_by_overlap))

if (respond_id == null) return {"errorMessage": "Not in a DPA"}

return respond_id.RESPOND_ID

 

 

The result in the template map, where it calculates appropriately:

SFM_TravisBott_0-1696968310709.png

 

The relevant parts of the script that deal with the form:

 

templateMapID = '' #ID scrubbed
templateMap = arcgis.gis.Item(gis, templateMapID)
workingMap = arcgis.mapping.WebMap(templateMap)
templateLayer = workingMap.layers[0]
templateLayerForm = templateLayer.formInfo

#j is the list element that's iterated on to produce the many views
#finalMap is the map created as part of the duplication process

openMap = arcgis.mapping.WebMap(finalMap)
form = openMap.forms.get(title = j + ' Comments')
form.title = 'Comment Layer Form'
form.update()

for layer in openMap.layers:
    layerName = j + ' Comments'
    if layerName == layer.title:
        layer.formInfo = templateLayerForm
        openMap.update()

 

 

The duplicated map's Arcade editor:

SFM_TravisBott_1-1696968852377.png

 

Duplicated map's results:

Note how the calculations for 'County' and 'Acres' still fires appropriately. 

SFM_TravisBott_2-1696968933158.png

Any help would be appreciated. 

 

1 Solution

Accepted Solutions
SFM_TravisBott
Occasional Contributor III

Disregard!

I found my issue - when I add the queried layer to the newly replicated maps I had a spelling error so the calculation didn't recognize it when called to the map. 

View solution in original post

0 Kudos
1 Reply
SFM_TravisBott
Occasional Contributor III

Disregard!

I found my issue - when I add the queried layer to the newly replicated maps I had a spelling error so the calculation didn't recognize it when called to the map. 

0 Kudos