Loop for stats on road signs - related records of poles inside a polygon

208
0
11-10-2023 05:30 AM
mfafard
New Contributor II

Hi

I'm trying to do an attribute rules to have the count of road signs who need to be fixed inside a polygon "Job" (and groupby road signs type). These road signs are in a related table (related to poles 1:N). My attribute rule is in this polygon (update a field to have the count and list of road signs type). I think I'm near the solution but still have an "Expected feature set" error line 18...

// Get feature classes into variables
var poles = FeatureSetByName($datastore, "Pole");
var polygoneselection = $feature;
// Make a variable for the related records
var relatedrecords = [];
// See if there are any poles intersecting the feature
var supportsIntersecting = Intersects(polygoneselection, poles);
// Loop through the records connected to the intersected poles
for (var pole in supportsIntersecting) {
var relatedPoleRecords = FeatureSetByRelationshipName(pole, "Pole_RoadSign");
// Add each related record to the array
for (var relatedRecord in relatedPoleRecords) {
Append(relatedrecords, relatedRecord);
}
}

// Group the related records by a field
var stats = GroupBy(relatedrecords, "interventionpanneautxt", [{ name: 'NbrInterventionParType', expression: '1', statistic: 'COUNT' }]);

// Create an array to hold the value that you get from the group by
var outputCount = [];
for (var f in stats) {
var numintervention = f.NbrInterventionParType;
Push(outputCount, numintervention);
}
// Console out the result to see it before saving
Console(outputCount);
// Return the final result
return outputCount;

 

 

Martin

0 Kudos
0 Replies