Hello,
I am trying to create a new data expression for an indicator element, which will combine the three layers from my map (which share the same attributes, but have different geometry types). I currently have an indicator for my point, line and polygon layer, but I would like a single indicator which will be able to count the number of features in each layer and sum together.
I have used various combinations of codes from other queries, but still have the same error message "Test execution error: Compilation error - Line : 4, 33: Identifier not recognized. Verify test data." Here is the code that I have so far:
// Portal
Portal("https://www.arcgis.com/");
// Create FeatureSet for points
var fs1 = FeatureSetByPortalItem(p,'2b84b6b511584a34807749f5d9969dd4&sublayer=0', 0, ['NatureReserve','Priority','IssueCategory','Notes','RecordDate','CompletionDate','CompletedBy','CreationDate','GlobalID'], true);
// Create Featureset for lines
var fs2 = FeatureSetByPortalItem(p,'2b84b6b511584a34807749f5d9969dd4&sublayer=1', 0,
['NatureReserve','Priority','IssueCategory','Notes','RecordDate','CompletionDate','CompletedBy','CreationDate','GlobalID'], true);
//Create Featureset for polygons
var fs3 = FeatureSetByPortalItem(p,'2b84b6b511584a34807749f5d9969dd4&sublayer=2', 0,
['NatureReserve','Priority','IssueCategory','Notes','RecordDate','CompletionDate','CompletedBy','CreationDate','GlobalID'], true);
// Create empty feature array and feat object for output
var features = [];
var feat;
// Iterate fs1
for (var feature in fs1) {
// Filter points by polygon
//var pts = Contains(feature, fs2);
// Create feature with aggregated values
feat = {
'attributes': {
'objecttype': ['PointObject'],
'NatureReserve': feature['NatureReserve'],
'Priority': feature['Priority'],
'IssueCategory': feature['IssueCategory'],
'Notes': feature['Notes'],
'RecordDate': feature['RecordDate'],
'CompletionDate': feature['CompletionDate'],
'CompletedBy': feature['CompletedBy'],
'CreationDate': feature['CreationDate'],
'GlobalID': feature['GlobalID']
}
};
// Push feature into array
Push(features, feat);
};
for (var feature in fs2) {
// Filter points by polygon
//var pts = Contains(feature, fs2);
// Create feature with aggregated values
feat = {
'attributes': {
'objecttype': ['PointObject'],
'NatureReserve': feature['NatureReserve'],
'Priority': feature['Priority'],
'IssueCategory': feature['IssueCategory'],
'Notes': feature['Notes'],
'RecordDate': feature['RecordDate'],
'CompletionDate': feature['CompletionDate'],
'CompletedBy': feature['CompletedBy'],
'CreationDate': feature['CreationDate'],
'GlobalID': feature['GlobalID']
}
};
// Push feature into array
Push(features, feat);
};
// Create dict for output FeatureSet
var out_dict = {
'fields': [
{'name': 'objecttype', 'type': 'esriFieldTypeString'},
{'name': 'NatureReserve', 'type': 'esriFieldTypeString'},
{'name': 'Priority', 'type': 'esriFieldTypeString'},
{'name': 'IssueCategory', 'type': 'esriFieldTypeString'},
{'name': 'Notes', 'type': 'esriFieldTypeString'},
{'name': 'RecordDate', 'type': 'esriFieldTypeDate'},
{'name': 'CompletionDate', 'type': 'esriFieldTypeDate'},
{'name': 'CompletedBy', 'type': 'esriFieldTypeString'},
{'name': 'CreationDate', 'type': 'esriFieldTypeDate'},
{'name': 'GlobalID', 'type': 'esriFieldTypeGlobalID'},
],
'geometryType': '',
'features': features
}; I am very new to data expressions so any and all suggestions would be greatly appreciated.
Thank you!