HOW TO
In ArcGIS Online, custom Arcade expressions can be used to configure the pop-ups in a web map. FeatureSet can be created from a feature layer in a portal item to display data from several layers and tables in the pop-ups. This article demonstrates the workflow to display fields from a separate hosted table in web map pop-ups using Arcade FeatureSet.
Note: This workflow can be used for a hosted feature layer with a related table, or between a hosted feature layer and a seperate hosted table. Ensure the hosted feature layer and the hosted table contain an attribute field of the same name.
In this example, the groundwater levels data in a hosted table is accessed as a FeatureSet to be displayed as related information in the groundwater well stations pop-ups.
The image below is the hosted table of the groundwater levels data to be displayed as related information in the pop-up. Stations are listed once or multiple times in the table.
The image below is the groundwater well station point feature pop-up containing only the information from the hosted feature layer.
var portal = Portal("https://www.arcgis.com") var RelatedTable = FeatureSetByPortalItem(portal, "<item ID>", <layer ID>, ['<field name>', '<field name>', '<field name>', '<field name>', '<date field name>'])
Note: To identify the item ID and the layer ID of the hosted table, on the item details page, click View next to the URL section to open the hosted table in ArcGIS REST Services Directory. The item ID is listed in Service ItemId, and the layer ID is listed in the parenthesis next to the layer or table.
var CommonAttr = $feature.<field name> var filterStatement = '<field name> = @CommonAttr' var relatedData = Filter(RelatedTable, filterStatement)
var relatedDataSorted = OrderBy(relatedData, '<date field name> ASC')
var popupString = '' for (var f in relatedDataSorted){ popupString += Text(f.<date field name>, 'MMMM Y') + TextFormatting.NewLine + "<Text> " + DefaultValue(f.<field name>, 'no data') + TextFormatting.NewLine + "<Text> " + DefaultValue(f.<field name>, 'no data') + TextFormatting.NewLine + "<Text> " + DefaultValue(f.<field name>, 'no data') + TextFormatting.NewLine + TextFormatting.NewLine } DefaultValue(popupString, 'No measurements to show')
This is the full Arcade expression used in this example.
var portal = Portal("https://www.arcgis.com") var RelatedTable = FeatureSetByPortalItem(portal, "426460a6ae7c43dcb", 0, ['STATION', 'MSMT_DATE', 'RPE_WSE', 'GSE_WSE', 'WSE']) var CommonAttr = $feature.STATION var filterStatement = 'STATION = @CommonAttr' var relatedData = Filter(RelatedTable, filterStatement) var relatedDataSorted = OrderBy(relatedData, 'MSMT_DATE ASC') var popupString = '' for (var f in relatedDataSorted){ popupString += Text(f.MSMT_DATE, 'MMMM Y') + TextFormatting.NewLine + "Depth to water surface (ft): " + DefaultValue(f.RPE_WSE, 'no data') + TextFormatting.NewLine + "Depth below ground surface (ft): " + DefaultValue(f.GSE_WSE, 'no data') + TextFormatting.NewLine + "Water Surface Elevation (ft): " + DefaultValue(f.WSE, 'no data') + TextFormatting.NewLine + TextFormatting.NewLine } DefaultValue(popupString, 'No measurements to show')
Note: Use the Test button to check the custom script in a variable. The return command can be added at the end of the script to test the script.
The related data from the hosted table is displayed in the pop-up using the custom Arcade expression.
Get help from ArcGIS experts
Download the Esri Support App