Select to view content in your preferred language

Web map popup arcade element doesn't honor new line

668
3
Jump to solution
03-13-2024 09:36 AM
Labels (2)
JohnLovette1
Occasional Contributor

I'm attempting to pull data from a feature service table and share information in a linked feature pop up using the Arcade content element. When testing the code in the AGOL Developers sandbox, the code returns the correct formatting with line breaks after each line, but when running in the pop up, everything is returned as a continuous string. I have tried both the '\n' and TextFormmatting.NewLine formats for the line break, with no success. Code and screenshots from web map and sandbox below...

 

var permits = FeatureSetByPortalItem(***);

var BAA = 'WITTENBURG'

var filterStatement = 'BAA = @BAA'
var BAApermits = Filter(permits, filterStatement)
BAApermits = OrderBy(BAApermits, "Permit_Date_Start ASC")

var countPermits = Count(BAApermits)

var fsprint = []
var n = 0

for(var r in BAApermits){
  var baaname = r.BAA
  var permitType = r.Permit_Type
  var permitStart = Text(r.Permit_Date_Start, "MM/DD/YYYY")
  var permitEnd = Text(r.Permit_Date_End, "MM/DD/YYYY")

  var permitDates = IIF(permitStart == permitEnd, permitStart, Concatenate([permitStart, '-', permitEnd], ' '))
  
  n += 1
  Push(fsprint, Concatenate([n, ". ", permitDates], ""));
}


var out = IIF(countPermits > 0,Concatenate(fsprint, TextFormatting.NewLine), '')

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

 

Sandbox (good formatting)

JohnLovette1_1-1710347710934.png

Pop up (bad formatting)

JohnLovette1_0-1710347677888.png

 

 

 

0 Kudos
1 Solution

Accepted Solutions
JohnLovette1
Occasional Contributor

Well, all it took was to post here and I figured it out...

 

Thanks to some suggested posts alongside this post, here and here, it seems like the issue has something to do with the return as text bit at the bottom, in which the formatting is stripped. For some reason, if i just change by code to return out, the whole section fails to render in the pop up. However, when i change the new line method to the HTML </br>, it works. The HTML tags seem to be honored within the text element, while the TextFormatting and \n options are not.

View solution in original post

0 Kudos
3 Replies
KenBuja
MVP Esteemed Contributor

Web Viewer Classic is built with JavaScript 3.x, which doesn't support '\n' or TextFormmatting.NewLine. The new Map Viewer is built with Javascript 4.x, which does support these.

0 Kudos
JohnLovette1
Occasional Contributor

I am using the new Map Viewer

0 Kudos
JohnLovette1
Occasional Contributor

Well, all it took was to post here and I figured it out...

 

Thanks to some suggested posts alongside this post, here and here, it seems like the issue has something to do with the return as text bit at the bottom, in which the formatting is stripped. For some reason, if i just change by code to return out, the whole section fails to render in the pop up. However, when i change the new line method to the HTML </br>, it works. The HTML tags seem to be honored within the text element, while the TextFormatting and \n options are not.

0 Kudos