Select to view content in your preferred language

Displaying Related Table Links in Popups - Arcade Expression Help

741
3
02-04-2024 07:58 PM
Labels (2)
Keenara
New Contributor

Hi Esri Community!

I'm working with a map in ArcGIS Online where I have a feature layer and a related table. I'm trying to create an Arcade expression to display links from a field called "Media Address" in the related table within the popup. 

I've tried the following Arcade expression, but didn't work as expected:

ndiaz_0-1707105501165.png

I'm getting the link addresses from the field "MediaAdresses" from the related table as text and not as "Links" 😞

So I'm looking for assistance in refining this expression or suggestions so I can get the actual link from this field from the related table. 

Any insights or alternative solutions would be greatly appreciated! Thank you

 

 

 

 

 

 

 

 




0 Kudos
3 Replies
KenBuja
MVP Esteemed Contributor

If you want a working link, you have to use an Arcade element. Here's one example of creating a popup with links from a related table

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>&nbsp •  <a href="${rec.FILENETLINK}">${rec.DOCGUID}</a>`;
} else {
  output = `There are ${relatedCount} surveys for this property:`;
  for (var rec in related) {
    output += `<br>&nbsp •  <a href="${rec.FILENETLINK}">${rec.DOCGUID}</a>`;
  }
}

return { 
	type : 'text', 
	text : output
}
LearnThenShare
Regular Contributor

Hi @KenBuja :  How can I see your example in actions?  Can I use this in a Map Viewer Classic embedded map that has the popup on the side panel?  I happen to be using the same source services as you are showing. Thanks!

 

0 Kudos
JohnEvans6
Regular Contributor

Try returning popupString in an object?

return {
  type: 'text',
  text: popupString
}
 
The formatting of your anchor tab looks a little off also since you're wrapping the field in quotes. Maybe something like:
 
var maddress = f.MediaAddress
popupString += `<a href = ${maddress }>Media Address</a>` + TextFormatting.NewLine