Related table data view in popup

593
7
03-16-2023 07:24 AM
BarryG
by
Occasional Contributor

Is it yet possible to publish a map service with a related table to AGOL, and view the related table data in a web map popup?

0 Kudos
7 Replies
jcarlson
MVP Esteemed Contributor

You can use Arcade to grab the attributes easily enough using the FeatureSetByRelationshipName function.

- Josh Carlson
Kendall County GIS
0 Kudos
BarryG
by
Occasional Contributor

Josh, I tried following that process but still did not display the related table info, but only the field name and object Object.

0 Kudos
jcarlson
MVP Esteemed Contributor

Well, once you have your FeatureSet, you need to grab individual features and work with them.

for (var feat in featureset) {
// do something here
}

Are you trying to get a single attribute from the related features? If there are multiple related features, how will you choose which to get?

- Josh Carlson
Kendall County GIS
0 Kudos
bsklaohfl
New Contributor III

Hi Barry,

I had this issue and hope to provide some insight with my code. The goal was to create a chart which referenced my related table data ("ADT_Data_Merge") with the related road ($feature.MRNLINKID). I created the related table between the ADT Data and MRNLINKID on Pro, but ended up needing to switch to creating a relationship class in order to export my map/relationship to AGOL map. Hope this helps a bit.

		// Set variable to MRNLINK IDS
		var Road = $feature.MRNLINKID
		// Set variable to related table (notice FeatureSetByRelationshipName)
		var Table = FeatureSetByRelationshipName($feature, "ADT_Data_Merge", ['Mean_ADT', 'Year'], false)
		// filter through table, matching the table's STATIONID with road variable)
		var AADT = OrderBy(Filter(Table, 'StationID = @Road'), 'Year')
		// this was copied and pasted from AGO community post, I only changed certain variables
		var chartValues = {}
		var chartNames = []
		for (var f in AADT) {
		        chartValues[Text(f.Year,'0000')] = Text(f.Mean_ADT,'###,###')
		        Push(chartNames, f.Year)
		    }
		return {
		    type: 'media',
		    title : 'AADT by Year',
		    description : 'Annual average daily traffic by year for this road',
		    attributes : chartValues,  // replace this dictionary with your own key-value pairs,
		    mediaInfos: [{
		        type : 'linechart', //linechart | barchart | piechart | columnchart
		        //title : '',
		        //caption : '',
		        altText : 'line chart showing traffic counts by year', //altText will be read by screen readers
		        value : {
		          fields: chartNames,  // choose what attributes to use in the chart
		          //normalizeField : '',  // the name of the attribute to normalize by or value 
		        }	  
		      }]
  }

 

0 Kudos
BarryG
by
Occasional Contributor

Thank you folks.  I have decided to instead create a model that will update values in a feature class from the table instead, as we have the identical fields already in the feature class.

0 Kudos
NorthSouthGIS
Occasional Contributor II

You can have a scheduled notebook run your model as a python script routinely in AGOL or enterprise

0 Kudos
NorthSouthGIS
Occasional Contributor II
0 Kudos