Dashboard Data Expression from Combining Layers into FeatureSet Empty

565
1
Jump to solution
11-19-2024 02:27 PM
Blevins_Mark
Frequent Contributor

Hello:

I'm trying to combine multiple layers in a data expression to use the resulting FeatureSet in a serial chart. When I run the code the table schema is returned but there are no records. I know it's something simple but alas.

//import variables
var portal = Portal('www.myportalurl.com');
var permitboundary_fs = FeatureSetByPortalItem(portal,'0ec1d6d3b5424618a0ac08129f7ac045',0,['name','area_acres'],false);
var disturbancearea_fs = FeatureSetByPortalItem(portal,'923a817eedd242d1af359a0963c6e9b0',0,['permitname','area_acres'],false);

//group filtered release layer by permit name
var permitboundary_final_fs = GroupBy(permitboundary_fs,'name',[{name: 'acrecalc', expression: 'area_acres', statistic: 'SUM'},])
var disturbancearea_final_fs = GroupBy(disturbancearea_fs,'permitname',[{name: 'acrecalc', expression: 'area_acres', statistic: 'SUM'},])

//create dictionary
var fsDict = {  
    'fields': [
      {'name': 'permit_name', 'type': 'esriFieldTypeString' },  
      {'name': 'permit_acres','type': 'esriFieldTypeInteger'},  
      {'name': 'disturbance_acres','type': 'esriFieldTypeInteger'},
    ],
    'geometryType': '',  
    'features': []
  };

var index = 0

//loop to populate dictionary
for (var permitboundaryfinalfeat in permitboundary_final_fs) {
    fsDict.features[index++] = {
      'attributes': {
        'permit_name': permitboundaryfinalfeat['name'],
        'permit_acres': permitboundaryfinalfeat['acrecalc']
      }
    }
}

for (var disturbanceareafinalfeat in disturbancearea_final_fs) {
    fsDict.features[index++] = {
      'attributes': {
        'permit_name': disturbanceareafinalfeat['permitname'],
        'disturbance_acres': disturbanceareafinalfeat['acrecalc']
      }
    }
}

//return dictionary
return FeatureSet(fsDict)

 Capture.JPG

I think I have to have a push command in there somewhere but that doesnt seem to do it?Thanks

0 Kudos
1 Solution

Accepted Solutions
Blevins_Mark
Frequent Contributor

issue was that original fields were double and i was trying to shove into inter field. rounding the acreage fields in the for loop solved the issue.

View solution in original post

0 Kudos
1 Reply
Blevins_Mark
Frequent Contributor

issue was that original fields were double and i was trying to shove into inter field. rounding the acreage fields in the for loop solved the issue.

0 Kudos