Hello all-
I am trying to create a popup in the new AGOL Map Viewer that includes related inspection data for water valves. Each valve has three inspection records related to it. With the help of this blog post (https://community.esri.com/t5/arcgis-online-blog/show-related-data-or-tables-in-pop-ups-with-arcade/ba-p/890530 I created this Arcade expression:
//access related data
var Inspections = (FeatureSetByName($datastore,"AM_Demo_Valve_Turning_Results2_2021"))
//filter related features by using a common attribute
var Valve_ID = $feature.Valve_ID
var filterStatement = 'Valve_ID = @Valve_ID'
//related features as a variable
var relatedData = Filter(Inspections, filterStatement)
//build popup string by iterating through all related features
var popupString = ''
for (var f in relatedData){
popupString += Text(f.Valve_ID) + TextFormatting.NewLine +
"Inspection Date: " +
(f.Inspection_Date) + TextFormatting.NewLine +
"Issues Observed: " +
(f.Issues_Observed) + TextFormatting.NewLine +
"Repairs Needed: " +
(f.Repairs_Needed) + TextFormatting.NewLine +
"Repairs Made: " +
(f.Repairs_Made) + TextFormatting.NewLine +
"Repaired Date: " +
(f.Repaired_Date) + TextFormatting.NewLine +
"Next Inspection Date: " +
(f.Next_Inspection_Date) + TextFormatting.NewLine +
TextFormatting.NewLine
}
return popupString
When I test the arcade expression, it looks just like what I want in the popup:

...but the popup looks like this, showing just one inspection record after the valve data, and including inspection fields that the Arcade expression doesn't specify:

I'm pretty clumsy with Arcade so I'm hoping it's a simple mistake... any help is much appreciated!