I am trying to show in AGOL, a Dashboard, and FieldMaps pop ups the last inspection date for an outfall inspection. My crew enters in the data in a Survey123 survey from a hyperlink in FieldMaps. The data from the survey is also input into a related table. I was trying to follow along with this blog post https://community.esri.com/t5/arcgis-online-blog/show-related-data-or-tables-in-pop-ups-with-arcade/...
but I'm not able to figure out the "//Filter related features by using a common attribute section". I think it has to do with my GUID field relating back to the GlobalID in the parent layer. Might also be that most of the data doesn't have a related entry to it. Below is the expression I have so far:
// Access 'Groundwater Levels Monthly Mean' table as a FeatureSet
var waterLevels = FeatureSetByPortalItem(Portal('https://www.arcgis.com'),
"4b21a92f2b38444793cf1ae1192476e4", 3, ['NodeNumber', 'MajorMinor',
'DateCurrent'])
// Filter related features by using a common attribute
var globalid = $feature.globalid
var filterStatement = 'parentglobalid = @globalid'
// Related features as a variable
var relatedData = Filter(waterLevels, filterStatement)
// Sort related features by oldest to newest
var relatedDataSorted = OrderBy(relatedData, 'DateCurrent DESC')
// Build the pop-up string by iterating through all related features
var popupString = ''
for (var f in relatedDataSorted){
popupString +=
"Outfall ID: " +
DefaultValue(f.NodeNumber, 'no data') + TextFormatting.NewLine +
"Last Formal Outfall Inspection: " +
DefaultValue(f.DateCurrent, 'no data') + TextFormatting.NewLine +
"Outfall Type: " +
DefaultValue(f.MajorMinor, 'no data') + TextFormatting.NewLine +
TextFormatting.NewLine
}
DefaultValue(popupString, 'No formal inspection data to show')
I was going section by section with the expression, so this does work and returns values in the field
// Acess 'Groundwater Levels Monthly Mean' table as a FeatureSet
var waterLevels = FeatureSetByPortalItem(Portal('https://www.arcgis.com'),
"4b21a92f2b38444793cf1ae1192476e4", 3, ['DateCurrent'])
return waterLevels
It is when I try the next section where I run into issues.
Parent layer "Outfalls", showing the GlobalID for NodeNumber WOC_24OF0_00.
Child layer, "DryWeatherScreening" showing the GUID field for WOC_24OF0_00, same as the parent layer's GlobalID.
I have seen some issues of this expression not showing up in Field Maps, but I am ok with that for now.
Thanks!
Janice
To post code:
You didn't adapt the filter query to your data. This should work:
// Filter related features by using a common attribute
var globalid = $feature.globalid
var filterStatement = 'GUID = @globalid' // GUID instead of parentglobalid
Sorry I didn't know how to add code like that!
I tried this below (excluding the pop-up section for now), and it doesn't pull any values.
// Access 'Groundwater Levels Monthly Mean' table as a FeatureSet
var waterLevels = FeatureSetByPortalItem(Portal('https://www.arcgis.com'),
"4b21a92f2b38444793cf1ae1192476e4", 3, ['NodeNumber', 'MajorMinor',
'DateCurrent'])
// Filter related features by using a common attribute
var GlobalID = $feature.GlobalID
var filterStatement = 'GUID = @GlobalID'
// Related features as a variable
var relatedData = Filter(waterLevels, filterStatement)
// Sort related features by oldest to newest
var relatedDataSorted = OrderBy(relatedData, 'DateCurrent DESC')
return relatedDataSorted
It is returning the related data but as a featureset, you need to parse it out. See solution here: https://community.esri.com/t5/arcgis-online-questions/display-related-records-in-a-popup-in-a-nice-t...