Arcade Text Constant for TextFormatting.NewLine is adding space instead of new line

60556
44
Jump to solution
12-22-2016 08:40 AM
CherylHagevik
Esri Contributor

I am trying to use TextFormatting.NewLine to add a new line to a Label Expression.

In the Playground, I am entering: $feature.name1 + TextFormatting.NewLine + $feature.name2

But the Result is showing a Space instead of a new line:

Am I setting up this expression correctly? 

Thanks!

44 Replies
MatthewMalone
Regular Contributor

Confirmed (see screenshot)!  Add the newline formatting in the current Map Viewer and then opened it up with the Beta and it displayed my two fields on separate lines as intended.  Thanks for the feedback!

-Matt

by Anonymous User
Not applicable

replace the part of the text line with + "\n" + to get the next line.

0 Kudos
OraneRoché
Emerging Contributor

Hello,

I know the first question was about the webmap, but I have the same problem in ArcGIS Pro (2.4.1).

The thing here is... that it seems to be random ?

(The advantage in ArcGIS Pro is that I have a simple workaround :

I don't use a line break in the expression, but a coma. I then use this coma as a line breaker in the "Position" menu :


)

PS : sorry for the french ArcGIS Pro

0 Kudos
by Anonymous User
Not applicable

Just add "\n".  For example with our sign database it looks something like this - $feature['vectorsde.GISDATA.TDOT_SIGNS.MUTCDCode'] +"\n" +
$feature['editsde.GISDATA.TDOT_SIGNS.CARTEGRAPHID']

OraneRoché
Emerging Contributor

Yeah, the problem is the same using \n or TextFormating.NewLine : randomly the line break just appears as a space (still in ArcGIS Pro, where there is a workaround so it's okay). 

0 Kudos
GeeFernando
Frequent Contributor

As Scott Moore (Olympia) pointed out - this works in ArcGIS API 4.x related products - Support Multi-Line Labels Using Arcade in AGOL 

But, if folks are still using ArcGIS API 3.x apps (e.g. Operations Dashboard) - this functionality wouldn't work - as stated in the Arcade Documentation.

An interim solution would be to - pass a HTML tag for line breaks instead - <br />

For example:

   {expression/expr0} + "<br />" + {expression/expr1}

This will cause any 4.x - apps and maps to look horrible, but will do the trick for 3.x related products.

HeatherStudley1
Occasional Contributor

I've been using TextFormatting.NewLine for a while now with my AGOL popups, but when I copied the code into a Portal application it doesn't work.  I have the NewLine embedded in an expression with an IF statement, so HTML is not an option.  Is this just a Portal thing?

0 Kudos
ChristopherBertrand
Regular Contributor

It likely has to do with the version of Portal that you're using.  I believe that they implemented Arcade line-breaks in the 10.8 version for Portal. You may need to update the version you use. 

MikeDiss-Torrance__TS
New Contributor

Is there a way to include a css style into the page?

I noticed that the ArcGIS API 3.x is missing the css class called "charNewLine" It is defined as white-space: pre-wrap;

Using the webbrowser developer tools, I was able to manually append that definition to the element and it worked as expected. In order to apply that, I would need to alter the existing jsapi-map.css file or include that styling definition to the index.html page of the dashboard. Is that even possible?

0 Kudos
MattCreaney
Frequent Contributor

@XanderBakker  is this still an issue?  I'm using arcade to create a feature set in Dashboards, works great in the Arcade editor but no new lines when viewed in the Dashboard....