Select to view content in your preferred language

Attribute expression that includes an ampersand doesn't display correctly in popup

205
3
Jump to solution
2 weeks ago
MappyIan
Occasional Contributor II

Some of my data has ampersand characters in the name field which I'm trying to use as the Title of the Field List element in my popup.  This works fine if I just use {name} in the relevant fields of my popup:

MappyIan_0-1717664056252.png

However some of my features do not have a value for the name attribute, so I created an attribute expression that uses the DefaultValue function to insert some default text if there is no name value, code below:

DefaultValue($feature.name, 'Unnamed building')
Using this expression in my popup, in the Title field of the popup it displays correctly (circled in green in the image below), but in the Title and Description fields of the Field List component all ampersands display as & (circled in red in the image below): 
MappyIan_1-1717665157946.png

 

I've tried using the REPLACE function to replace '&' with '&' but that doesn't resolve the issue.

It's annoying that it works fine in the Title field of the Popup, but not in the Title and Description fields of the Field List component, as it's the Title of the Field List that I want to use it in.  The inconsistency of this makes me think it's a bug, I can't imagine this is deliberate behaviour.

A workaround is to use the REPLACE function and replace '&' with 'and', but this is a bit misleading as users will be using the search function to search for buildings by their 'name'.  If we display the name as 'Bar and SCR' users will expect that is how the data is stored and would logically search for 'bar and scr' rather than 'bar & scr'.

I'd love to know if there is a way to resolve this without having to use the REPLACE function to replace '&' with 'and'.

0 Kudos
1 Solution

Accepted Solutions
MappyIan
Occasional Contributor II

In case anyone else encounters this issue I reported it to ESRI UK Support and they've logged it as a bug for ESRI Inc to investigate.  I'll post any updates here.  Bug ID is: https://support.esri.com/en-us/bug/BUG-000168321 

View solution in original post

3 Replies
epckay
by
New Contributor II

Have you tried && ?

0 Kudos
MappyIan
Occasional Contributor II

Hi @epckay, thanks for the suggestion but replacing '&' with '&&' doesn't fix the problem.  This is the code I used in my expression, and the results are shown below.

DefaultValue(replace($feature.name, "&","&&"), 'Unnamed building')
MappyIan_0-1718096154346.png
0 Kudos
MappyIan
Occasional Contributor II

In case anyone else encounters this issue I reported it to ESRI UK Support and they've logged it as a bug for ESRI Inc to investigate.  I'll post any updates here.  Bug ID is: https://support.esri.com/en-us/bug/BUG-000168321