Select to view content in your preferred language

Showing Hyperlink from Feature Set in Arcade Expression

119
2
Jump to solution
Tuesday
Labels (1)
CamTurney_CityofCF
Emerging Contributor

I have an Arcade expression that utilizes two different feature services. The first feature service is of some points, with a name field. The second is a feature service from a Survey123 form, which contains all the data I need. I am using both to show all survey records associated to existing set locations in one popup. I managed to use a feature set expression to grab all the survey data and it's displayed how I want. However, since attachments (photos) are allowed, I need these to be shown as well. The arcade expression uses a for-loop to go through each survey and output each by submission. I can only manage to get the links to post on the popup as a string,, but cannot get them to be hyperlinked. Is there a way to get the string to be hyperlinked within my expression, and preserve the format?

Thanks in advance!

 

var p = Portal("https://arcgis.com");
var features = FeatureSetByPortalItem(p, "<feature ID>", 0, ['zone_name','maintained_yn', 'maintained_date', 'Maint_Activity','groups_involved', 'notes', 'picture'])

var plot = $feature.Zone_Name
var filterStatement = 'zone_name = @plot'
var relatedData = Filter(features, filterStatement)

var relatedDataSorted = OrderBy(relatedData, 'maintained_date ASC')

var popupString = ''
for (var f in relatedDataSorted){
  var pic = f.picture
  popupString += text(f.maintained_date, 'MM/DD/YYYY') + TextFormatting.NewLine +
  "Native Plant Zone: "+f.zone_name + TextFormatting.NewLine +
  "Maintained?: " + f.maintained_yn + TextFormatting.NewLine +
  "Maintenance Activity: " + f.Maint_Activity + TextFormatting.NewLine +
  "Groups Involved: " + f.groups_involved + TextFormatting.NewLine +
  "Notes: " + f.notes + TextFormatting.NewLine +
  pic + TextFormatting.NewLine + TextFormatting.NewLine
}
return popupString
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

You'll want to use an Arcade element instead of a text element to show clickable links. Here's one way to do this, which also uses template literals

var p = Portal("https://arcgis.com");
var features = FeatureSetByPortalItem(p, "<feature ID>", 0, ["zone_name", "maintained_yn", "maintained_date", "Maint_Activity", "groups_involved", "notes", "picture"]);

var plot = $feature.Zone_Name;
var filterStatement = "zone_name = @plot";
var relatedData = Filter(features, filterStatement);

var relatedDataSorted = OrderBy(relatedData, "maintained_date ASC");

var popupString = "";
for (var f in relatedDataSorted) {
  //var pic = f.picture;
  popupString += `${text(f.maintained_date, "MM/DD/YYYY")}<br/>
    Native Plant Zone: ${f.zone_name}<br/>
    Maintained?: ${f.maintained_yn}<br/>
    Maintenance Activity: ${f.Maint_Activity}<br/>
    Groups Involved: ${f.groups_involved}<br/>
    Notes: ${f.notes}<br/>
    <a href="${f.picture}">Photo</a><br/><br/>`
}
return { 
 type : 'text', 
 text : popupString 
}

 

View solution in original post

2 Replies
KenBuja
MVP Esteemed Contributor

You'll want to use an Arcade element instead of a text element to show clickable links. Here's one way to do this, which also uses template literals

var p = Portal("https://arcgis.com");
var features = FeatureSetByPortalItem(p, "<feature ID>", 0, ["zone_name", "maintained_yn", "maintained_date", "Maint_Activity", "groups_involved", "notes", "picture"]);

var plot = $feature.Zone_Name;
var filterStatement = "zone_name = @plot";
var relatedData = Filter(features, filterStatement);

var relatedDataSorted = OrderBy(relatedData, "maintained_date ASC");

var popupString = "";
for (var f in relatedDataSorted) {
  //var pic = f.picture;
  popupString += `${text(f.maintained_date, "MM/DD/YYYY")}<br/>
    Native Plant Zone: ${f.zone_name}<br/>
    Maintained?: ${f.maintained_yn}<br/>
    Maintenance Activity: ${f.Maint_Activity}<br/>
    Groups Involved: ${f.groups_involved}<br/>
    Notes: ${f.notes}<br/>
    <a href="${f.picture}">Photo</a><br/><br/>`
}
return { 
 type : 'text', 
 text : popupString 
}

 

CamTurney_CityofCF
Emerging Contributor

This worked! Thanks! I will remember this going forward!

0 Kudos