Browsing Related Data in Pop Up (Relationship not Found in Map)

317
1
03-30-2023 06:35 AM
Rice_GIS
New Contributor III

Hello,

I'm trying to use the sample code in this example for my code:

https://developers.arcgis.com/javascript/latest/sample-code/popuptemplate-browse-related-records/ 

I rewrote the script to fit my data for only 1 layer and 1 non-spatial table, all of which sit on an ArcServer as a FeatureServer. Other than the layer and table I'm bringing in, all of the code is the same. 

Here's where I bring in my layer and set up the pop up to include RelationshipContent. (URL changed to protect organization identity)

const countyLayer = new FeatureLayer ({
		url: "https://FeatureServer/0",
		title: "Counties",
		outFields: ["*"],
		popupTemplate: {
		  title: "{NAME} County",
		  outfields: ["*"],
		  returnGeometry: true,
		  fieldInfos: [
		     {
			   fieldName: "NAME",
			   label: "County"
			  },
			  {
			  fieldName: "FREQUENCY",
			  label: "Number of Species"
			  }
			],
		  content: [
		  {
		  type: "fields"
		  },
		  
		  {
		  type: "relationship",
                 //relationshipID is as seen on the web feature service. 
		  relationshipId: 2,
		  description: "Sensitive Species that are known to occur within {NAME} County",
		  
		  displayCount: 10,
		  
		  title: "County Records",
		  
		  orderByFields: {
			field: "CommonName",
			order: "asc"
		    }
		  }
		 
		 ]
		}
	   });

Then I bring in my non-Spatial table which I can confirm is related to my layer when i inspect the Rest URL.

const countyTable = new FeatureLayer({
	   url:"https://FeatureServer/3",
	   title: "County Records",
	   popupTemplate: {
	     
		 fieldInfos: [
		 {
		   fieldName: "NAME",
		   label: "County"
		 },
		 {
		   fieldName: "SpeciesGroup",
		   label: "Species Group"
		  },
		 {
		   fieldName: "CommonName",
		   label: "Common Name"
		  },
		 {
		   fieldName: "ScientificNameCurrent",
		   label: "Scientific Name"
		  },
		 {
		  fieldName: "ProtectionLevels",
		  label: "Protection Levels"
		  }
		 ],
		 title: "{SpeciesGroup} - {CommonName}",
		 content: [
		  {
		    type: "fields"
		  }
		 ]
		}
	});

Everything loads into my map fine, except when I click a county for the pop up, I get this error.

Rice_GIS_0-1680182789391.png

// Load the non-spatial table and add to the map.
        countyTable.load().then(() => {
          map.tables.add(countyTable);
        });
	
	// Add all the layers to map since they all have relationships.
        map.add(countyLayer);

This is my call to load layer/table into the map. This occurs directly beneath the last const to bring in the table. At first, it wasn't working when I realized these layers were a "MapServer" and not a "FeatureServer" in the sample. So we were able to publish my layer/table as a "FeatureServer", but it's still not loading my relationships. Is there a limitation at this point I'm not aware of? In my fields, I'm naming the fields as they are in the data but not their alias, but not sure that's the issue.  Any help with this would be greatly appreciated.

 

0 Kudos
1 Reply
LaurenBoyd
Esri Contributor

Hi @Rice_GIS -

Browsing related records within a popup is only supported for ArcGIS Online hosted feature services at the moment. This limitation is outlined in the RelationshipContent API documentation. We plan to support ArcGIS Enterprise services in a future release.

Lauren
0 Kudos