Select to view content in your preferred language

Related data in AGOL popups

2163
3
Jump to solution
10-26-2021 01:22 PM
Hatsocks
Emerging Contributor

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:

JosephineHatton_0-1635278516959.png

...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:

JosephineHatton_1-1635278644073.png

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

0 Kudos
1 Solution

Accepted Solutions
DominicRoberge2
Frequent Contributor

code looks good, are you sure your "expression"  is listed in your list of pop-ups fields?

View solution in original post

0 Kudos
3 Replies
DominicRoberge2
Frequent Contributor

code looks good, are you sure your "expression"  is listed in your list of pop-ups fields?

0 Kudos
Hatsocks
Emerging Contributor

Ha! No, it wasn't!  That was easy-- thank you so much!

0 Kudos
DominicRoberge2
Frequent Contributor

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.