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/... 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!
Solved! Go to Solution.
code looks good, are you sure your "expression" is listed in your list of pop-ups fields?
code looks good, are you sure your "expression" is listed in your list of pop-ups fields?
Ha! No, it wasn't! That was easy-- thank you so much!
those little things 🙂
FYI, if you try to use that expression in Fields Maps... it won't work..I have been working with ESRI Tech Support on that and this morning they logged it as a bug (I was using almost the same code to bring attachments in the popup)
Reference number:- BUG-000144024
Public Status:- New
Synopsis:- The arcade expression to count the number of attachments fails to honor in the ArcGIS Field Maps.