[GIS] Related Tables in ArcGIS Online

arcgis-onlinepopuprelationship-class

I've created a relationship class in Desktop and published to ArcGIS Online as a service. The relationship still exists between my table and feature service but when I try to add one of the fields from the related table to my POP-UPS all I get is the count showing how many rows were returned in the related table. What I'd like is a ordered list showing the actual values, not the count. The cardinality of my join is many rows in the table to one value in the feature service (many:one). I find it odd that ESRI would include this functionality in their popups if all you could get is the count though I've read where a few others had the same issue. Perhaps Arcade expressions provide the answer. Does anybody know if it's possible to show the values from related tables in ArcGIS Online Pop-Ups?

Best Answer

It is possible to do using Arcade expressions. See example here of a 1:M join between parcels and addresses: Residential Permit Parking

I'm not sure this is the most efficient way to accomplish this, but it works:

  1. Get the related table using FeatureSetById
  2. Use the filter function to narrow the results to the rows you are interested in.
  3. Use a for loop to interate through the feature set. This is where you can format the data to print however you would like.
//Get related table
var ineligibleAddresses = FeatureSetById($datastore, '32')

//Get related features from table
var relatedAddresses = Filter(ineligibleAddresses, 'Parcel = '+$feature.Parcel_Nbr)

//String to print
var parcelIneligible = ''

//Iterate through each row and format
for(var address in relatedAddresses) {
    parcelIneligible = parcelIneligible + address.HouseNbr + ' '
    + address.StreetDir + ' ' 
    + address.StreetName + ' '
    + address.StreetType + ' '
    + address.Note + ' '
    + TextFormatting.NewLine
}

//print related addresses
parcelIneligible
Related Question