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?
4 Answers
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:
- Get the related table using FeatureSetById
- Use the filter function to narrow the results to the rows you are interested in.
- 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
The web maps themselves will only display statistical information in the pop-ups when the join is one-many. Was able to get the information working in one of the templates provided by the web app builder. Given web app builder seems to be the path forward, I'll accept it as a solution.
It is possible to do this with Arcade expressions. You can see a sample expressions here.
var related_table = FeatureSetById($datastore, "1");
var filter_query = "parentglobalid = '" + $feature["globalid"] + "'";
var related_data_filtered = Filter(related_table, filter_query);
var related_data_filtered_count = Count(related_data_filtered);
var output = "";
if (related_data_filtered_count > 0) {
output = "Total of " + related_data_filtered_count + " records";
for (var relatead_data_row in related_data_filtered) {
output += TextFormatting.NewLine + relatead_data_row.FieldName1 + " - " + relatead_data_row.FieldName2;
}
} else {
output = "No Related Records...";
}
return output;
Best to use a custom attribute display for the popup.
Not an exact solution to your posted question but a workaround for similar functionality if you are still interested...
Rather than creating a 1:m relate, you can create and calculate a field in your feature class that contains a string representation of your list of related records, separated by a delimiter.
Then, in ArcGIS Online, you can configure an attribute expression to replace the delimiter you chose with '\n', which will put each item on a new line.
(screenshot of the results)
-
Good idea, PAW. Can you share an example of the Arcade expression you would use for this? I'm having a hard time getting more than just the last related record name to populate the field. FYI: I'm using an attachment table, which Arcade can access. Commented Mar 24, 2021 at 20:42