Select to view content in your preferred language

Arcade code help. Add prefix, suffix, and new line and parse by comma

1490
2
09-17-2021 02:49 PM
JohnDriessen
Emerging Contributor

Hi folks, I have an Arcade attribute expression puzzler.  

A bit of background, I've created an attribute expression to display "Permit Numbers" from a related table in the feature service pop-up.  My only problem is that I need to add the URL prefix and suffix to those numbers to create the hyperlink as well as a NewLine.

 

//code sample

//Attempt 2
//join field id
var id = $feature.ParcelID;
var relatedtable = FeatureSetById($datastore, "1");
var filtereddata = Filter(relatedtable, "ParcelID = @id");
var permits = []
var index = 0;
for (var permit in filtereddata) {
permits[index] = permit["PermitNumber"];
index++;
}

return Concatenate(permits, ',')

 

//result pop-up

Permit Numbers2013-MSS-SWR-00211,EXC120338,EXC02-1861,EXC052208,2016-MSS-SWR-00488,13928,21394,2013-MSS-EXC-00009,2013-MSS-EXC-00305,2016-MSS-EXC-00742,2016-MSS-EXC-00743

 

//new format needed

https://asbuilts.ci.missoula.mt.us/scards/2013-MSS-SWR-00211.pdf

https://asbuilts.ci.missoula.mt.us/scards/EXC120338.pdf

0 Kudos
2 Replies
DavidPike
MVP Frequent Contributor

Not too sure on the newline.  re prefix and suffix, I don't know if I'm missing something so apologies if I've misunderstood.

edit, maybe try just + '\n' also or '\r\n' or "\x0d\x0a" - Solved: Arcade Text Constant for TextFormatting.NewLine is... - Esri Community

 

permits[index] = 'https://asbuilts.ci.missoula.mt.us/scards/' + permit["PermitNumber"] + '.pdf'

 



0 Kudos
JohannesLindner
MVP Frequent Contributor
var id = $feature.ParcelID;
var relatedtable = FeatureSetById($datastore, "1");
var filtereddata = Filter(relatedtable, "ParcelID = @id");
var permits = []

var url_pre = "https://asbuilts.ci.missoula.mt.us/scards/"
var url_post = ".pdf"
for (var permit in filtereddata) {
  permits[Count(permits)] = url_pre + permit["PermitNumber"] + url_post
  // in ArcGIS Pro 2.8 or later you can do
  // Push(permits, url_pre + permit["PermitNumber"] + url_post)
}

// if you show the popup's normal attribute table, one of these should work
return Concatenate(permits, TextFormatting.NewLine)
return Concatenate(permits, "\n")
// if you show custom HTML code, this should work
return Concatenate(permits, "<br/>")

 

Note that there is currently no easy way for the popup to actually format those urls as links. Your users will have to copy/paste them.


Have a great day!
Johannes
0 Kudos