Configuring a popup with related tables using Arcade.

1472
1
08-31-2021 10:12 AM
Labels (1)
ColeNelson62077
New Contributor

Hello, this is actually my first post and I'm also new to Arcade, so hopefully I'm in the right place. 

I have a parent feature layer called "File_Number"ColeNelson62077_1-1630429362578.png

and a child table called "Occupancy"

ColeNelson62077_2-1630429473440.png

I've created a 1:M relationship class for them, using their File Number fields in ArcGIS Pro, and then uploaded them to ArcGIS Online. 

What I'm trying do is configure the popup for the File Number feature layer to display all of the occupants associated with each file number from the Occupancy table.  The occupants are found in the Building column which I circled in the screenshot.  Here is a code that I found on the internet and  have been currently working with.

 

var occupants = OrderBy(FeatureSetByRelationshipName($feature,"ISRB_WebMapFeatures.DBO.Occupancy"), "Building");
var cnt = Count(occupants);
var occupancy = "";
if (cnt > 0) { var info = First(occupants);
occupancy = info.Building;
}

return occupancy;

 

It will almost do what I want, however I want all the values from the Building field associated with the file number, not just the first one.  I'm assuming it has to do with the First global, however whenever I try to remove it or try anything else I get an error.  Any help would be greatly appreciated and thank you so much.

 

 

   

0 Kudos
1 Reply
LeonS
by
Occasional Contributor III

Instead of just grabbing the first record of your result set, you want to iterate through the set to get all the related records from your table.  This blog article (link below) looks like it does a nice job of walking through the process of getting all related records and adding the results to a pop-up.  

 

https://community.esri.com/t5/arcgis-online-blog/show-related-data-or-tables-in-pop-ups-with-arcade/...

 

 

Leon

0 Kudos