Select to view content in your preferred language

Sweet for ArcGIS - return multiple features in execution task array

168
0
11-11-2024 07:05 AM
Labels (2)
Julia8
by
New Contributor

Hi all,

 

I am a UK-based user of Sweet for ArcGIS web app builder. I am trying to build a code for the execution task command to add records. While a single feature is a no-brainer, I am struggling with multiple ones.  I know that output must be an array of features. 

I have a polygon layer and look for any intersecting polygon features from different layers. I use an empty polygon layer and match fields as a target layer. From the console, I can see that it identifies correct polygons and returns them as an array of x features. 

 

//sssi lay
var intersecting_field = FeatureSetByName($map,"Sites of Special Scientific Interest Units (England)", ['SSSI_NAME'], true);

//intersecting polygons
var intersecting_featset = FeatureSetByName($selection,"Test", ['Project_Code'], true);

//pull feature with geometry from selected polygon
var SelPoly = First(intersecting_featset)

// intersection between selpoly and sssi
var InterPoly = Intersects(intersecting_field, SelPoly)


//array to input results
var SSSIarray = []
var feat;

//loop through intersecting polygons and push to constraints
for(var f in InterPoly) {
    var SSSIfeature = f.SSSI_NAME
        feat = [{
            geometry:  {f,
            attributes: {
                Project_Code: f["SSSI_NAME"],
                Constraint_type: text('SSSI'),
            }
        }}]
        
    Push(SSSIarray, feat) 
}

//find the features in Array
var ReturnValues = Distinct(Splice(SSSIarray))


return ReturnValues;

 

 From the console, I can see that it identifies correct polygons and returns them as an array of x features. Text output also has correct attributes, including geometries and paired Project Code and SSSI Name.  Code executes but nothing is added to the target layer... Any ideas about what may be causing the issue here?

0 Kudos
0 Replies