Select to view content in your preferred language

Sorting for a Popup in Web Viewer using an Arcade element

970
2
Jump to solution
09-21-2022 04:36 PM
John_Shell
New Contributor III

I am trying to figure out how to sort my field called "Name" in ascending order in the arcade element expression. I wasn't able to find an HTML tag and I tried used using Order By but I couldn't get it to work. Any help would be greatly appreciated.

Thank you,

John

/*
Choose a template from the Templates tab to get started with creating different content types for your pop-up.
To learn more about using Arcade to create pop-up content visit:
https://developers.arcgis.com/arcade/guide/profiles/#popup-element
*/

var areas =FeatureSetByName($map,"Neighborhood Council Districts (Tacoma)");
var Onefifty = Buffer($Feature, -150, 'feet')
var countp = Intersects(areas,Onefifty);

var result = "";
for (var item in countp){
var name = item["Neighborhood"];
var url = item["URL"]
result += `<a href="${url}" target="_blank"><span style="color:#287fb8;"><u>${name}</a><br/>`
}


return {
type : 'text',
text : result
}

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

What happens when you change line 3? I'm assuming when you say "sort my field called 'Name'", you mean the 'Neighborhood' field.

var areas =FeatureSetByName($map,"Neighborhood Council Districts (Tacoma)");
var Onefifty = Buffer($Feature, -150, 'feet')
var countp = OrderBy(Intersects(areas,Onefifty), 'Neighborhood ASC');

var result = "";
for (var item in countp){
  var name = item["Neighborhood"];
  var url = item["URL"]
  result += `<a href="${url}" target="_blank"><span style="color:#287fb8;"><u>${name}</a><br/>`
}


return {
  type : 'text',
  text : result
}

 

View solution in original post

2 Replies
KenBuja
MVP Esteemed Contributor

What happens when you change line 3? I'm assuming when you say "sort my field called 'Name'", you mean the 'Neighborhood' field.

var areas =FeatureSetByName($map,"Neighborhood Council Districts (Tacoma)");
var Onefifty = Buffer($Feature, -150, 'feet')
var countp = OrderBy(Intersects(areas,Onefifty), 'Neighborhood ASC');

var result = "";
for (var item in countp){
  var name = item["Neighborhood"];
  var url = item["URL"]
  result += `<a href="${url}" target="_blank"><span style="color:#287fb8;"><u>${name}</a><br/>`
}


return {
  type : 'text',
  text : result
}

 

John_Shell
New Contributor III
That code worked perfectly.
Thank you,
John
0 Kudos