Select to view content in your preferred language

Arcade Label error when ampersand "&" is part of the label

2136
2
Jump to solution
05-24-2021 05:02 AM
RobertBorchert
Honored Contributor

I am using Pro  and Arcade scripting for creating labels.  We have a field set aside for labels.

$feature.MBLABEL

The script looks like

"<fnt size= '8'>" + $feature.MBLABEL + "</fnt>"

For each and every label it works fine. However, if there is an Ampersand in the MBLABEL field it does not

Example the Text String in the field is "Cooperative Light & Power HQ" 

The below image shows how it breaks the label. Removing the Ampersand fixes the issue.

 

RobertBorchert_0-1621857587851.png

Is this a known issue with Arcade?

Removing the <fnt> scripting fixes it as well. But then why bother with Arcade at all.

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

This is an issue with labeling in general, not in just Arcade. From the documentation:

The ampersand (&) and angle bracket (<) are special characters and are not valid in your text if formatting tags are used. Use the equivalent character codes &amp; and &lt; instead.

If you have special characters embedded in the values of the label field, you can replace them dynamically using a simple label script.

"<BOL>" + replace($feature.Notes, "&", "&amp;") + "</BOL>"

View solution in original post

2 Replies
KenBuja
MVP Esteemed Contributor

This is an issue with labeling in general, not in just Arcade. From the documentation:

The ampersand (&) and angle bracket (<) are special characters and are not valid in your text if formatting tags are used. Use the equivalent character codes &amp; and &lt; instead.

If you have special characters embedded in the values of the label field, you can replace them dynamically using a simple label script.

"<BOL>" + replace($feature.Notes, "&", "&amp;") + "</BOL>"
RobertBorchert
Honored Contributor

Thanks. I will use your answer.

It really does not make sense as it is part of a text string inside of an attribute.