Hello! I need assistance with adding related table fields to a polygons popup. The source data is below.
Thank you! @JohanLei1
polygon: https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Property_and_Land_WebMercator/MapServer/40
related table: https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Property_and_Land_WebMercator/MapServer/69
With some more work, I was able to get a clickable link for each related survey. This is using the popup content element. Add in an Arcade element and use this script
var related = FeatureSetByRelationshipName($feature, "DCGIS.SURDOCS"); var relatedCount = count(related); var output; if (relatedCount == 0) { output = `<p>There are no surveys for this property.<\p>`; } else if (relatedCount == 1) { var rec = First(related); output = `There is 1 survey for this property: <br>  • <a href="${rec.FILENETLINK}">${rec.DOCGUID}</a>`; } else { output = `There are ${relatedCount} surveys for this property:`; for (var rec in related) { output += `<br>  • <a href="${rec.FILENETLINK}">${rec.DOCGUID}</a>`; } } return { type : 'text', text : output }
All the attributes from each related record are available to the popup, as shown in this script.
var counter = 1; var related = FeatureSetByRelationshipName($feature, "DCGIS.SURDOCS"); var relatedCount = count(related); var output; for (var rec in related) { output += `Record ${counter++}` for (var attribute in rec){ output += `${TextFormatting.NewLine}• ${attribute}: ${rec[attribute]}` } if (counter <= relatedCount) output += `${TextFormatting.NewLine}${TextFormatting.NewLine}` } return output;
This expression will show each of the surveys' url
var related = FeatureSetByRelationshipName($feature, "DCGIS.SURDOCS"); var output = `${count(related)} survey`; if (count(related) != 1) output += "s"; for (var rec in related) { output += `${TextFormatting.NewLine}• ${rec.FILENETLINK}` } return output;
. However, I don't think there's currently a way to make each of them clickable
Give this a try:
var rec = First(FeatureSetByRelationshipName($feature, "DCGIS.ITSPE", ['BIDNAME', 'BIDTOTALDUE', 'BIDCOLLECTED', 'BIDBALANCE'])); return `${rec.BIDNAME} • Total Due: ${Text(rec.BIDTOTALDUE, '$#,###.00')} • Collected: ${Text(rec.BIDCOLLECTED, '$#,###.00')} • Balance: ${Text(rec.BIDBALANCE, '$#,###.00')}`
Hi @KenBuja
Can you assist again with a similar expression? FYI I am still on Classic Map if that matters here.
The polygon: https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Property_and_Land_WebMercator/MapServer/40
The related table: https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Property_and_Land_WebMercator/MapServer/53
The fields from the related table for the popup:
Thank you!
Hi @KenBuja : Thank you again for the additional expression! This is very promising. I do wonder what are the technical limitations specific to bringing in the full data from related tables. I will implement the expression that you provided and let you know when it works (and accept as solution), and I will let you know if I find out how to make all the link data actual links to the image. Thank you!!!
Hi @KenBuja , Thank you for the expression. If I am looking to add the one or more attributes from the related table, not simply a count, is there an additional Arcade expression that makes that happen? The related table has an image type field and an image URL. I would like the image type attribute(s) and the image URL(s) to show in the popup - not only accessible in the "related tables" link at the bottom. Thank you!
This expression will show how many surveys from the table have been done at a property.
var related = FeatureSetByRelationshipName($feature, "DCGIS.SURDOCS"); var output = `${count(related)} survey`; if (count(related) != 1) output += "s"; return output;
You can use that expression in the popup like this
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.