How do I create multiline labels using Arcade functions?

20505
18
02-15-2017 06:10 AM
MaryAnnSteinmetz
Occasional Contributor

I'm trying to label polygons using two separate fields. I would like this to show on two separate lines. In desktop I use the vbnewline command. Is there an equivalent in Arcade?

18 Replies
by Anonymous User
Not applicable

Ooops, sorry about it. My bad.

But, it would be great to get this working again

Gee

0 Kudos
DanPatterson_Retired
MVP Emeritus

Of course, it depends on what you are labelling and not just wanting to use Arcade.

python is more mature if you are in a pinch... Arcade is still under development

0 Kudos
TanyaWinemiller
Emerging Contributor

Perfect! Thank you!

DavidForbuss1
Frequent Contributor

Did this ever get resolved?  Will it work in the expression builder now?

Update: I just tried this and unfortunately it doesn't work.  Strangely, the TextFormatting.NewLine option is available under the "Constants" tab, but when you click the help button you get this message even though the test box is showing it as working:

GeeFernando
Frequent Contributor

Hi David Forbuss, this works in ArcGIS API 4.x related products - Support Multi-Line Labels Using Arcade in AGOL 

But, if you're still using ArcGIS API 3.x apps (e.g. Operations Dashboard) - this functionality wouldn't work - as you mentioned.

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.

MatthewDuffy
Frequent Contributor

Although the note remains the same about the API 3x, based on my preview from AGOL,

I think this is working now maybe...?

Expression:

$feature["RESP_DATE"] + TextFormatting.NewLine + $feature.CRRALL

Result:

2020-05-05T08:00:00-04:00

67.1

0 Kudos
MatthewDuffy
Frequent Contributor

Uhp, disregard, it did not work, sorry

0 Kudos
Kelin_Field
Emerging Contributor

The odd thing I have noticed is that even using Python's  "\r\n"  at the end of each line will give the correct preview but once you accept the expression the text returns to a single line in map.

0 Kudos
TylerScott2
Emerging Contributor

Having the same issue here. TextFormatting.NewLine works as it should in the preview, but once you accept the expression the text returns to a single line of text in the map. 

0 Kudos