Hello,
I am working on a project that requires me to count the number of hydrants that have not been inspected within the last 5 years, and I need to use arcade to do it.
I am able to get the feature set of the inspection dates pulled through the portal, but I am unable to filter out for the year (ex all 2017 hydrants need to be serviced) and then filter further for the ones that have been done 5 years prior to this year (not from this today).
var fs = FeatureSetByPortalItem(
Portal('https://www.arcgis.com'),
'9e935789e337432a8314f0ede0f9ac7c',
0,
[
'InspectionDate',
],
false
);
// List of inspectors per field per feature; empty for now
var out_dict = {
fields: [{name: 'inspdate', type: 'esriFieldTypeDate'}],
geometryType: '',
features: []
}
// Iterate over each feature in the layer
for (var f in fs){
Push(
out_dict['features'],
{attributes:
{inspdate: Number(f['InspectionDate'])
}
}
)
}
//Return populated out_dict as FeatureSet
var inspections = FeatureSet(Text((out_dict)))
var yearDate = year(inspections)
return year
I have gotten to the point where I am trying to pull the year out, but am unsuccessful. This means that I should be good down to line 30 before I get the error. Any assistance would be appreciated, thanks!