Escape special characters in Dynamic Text (Data Driven Pages)

3167
11
08-17-2020 08:19 AM
AndrewBowne
Occasional Contributor III

Hi,

I'm looking to escape special characters when using Dynamic attribute text with Data Driven Pages using ArcGIS Pro.  I have some attribute values that include amphersands and it's throwing my formatting expressions for a loop.  I know with map labels it's pretty easy to escape them by using a python expression however I'm not sure how to do this with dynamic text on the layout.  Any suggestions?

0 Kudos
11 Replies
DanPatterson
MVP Esteemed Contributor

don't know if your situation applies to this, but the formatting info might be useful

https://community.esri.com/thread/258472-special-characters-with-text-formatting-tags 


... sort of retired...
0 Kudos
AndrewBowne
Occasional Contributor III

Thanks, Dan.  This works great when labeling features on the map however I'm talking about Dynamic Text on the layout.  I don't see a way to use these types of expressions when it comes to Dynamic Text.  One thing I do not want to do is go in and modify my Attribute table in order to get it to work.

0 Kudos
JayJohnsonWashoeCounty
Occasional Contributor III

Can you provide a screen shot or example?  In Pro 2.6, when I insert an Attribute as Dynamic Test in my Data Driven Pages map book, an attribute value including an & works just fine.  What formatting are you trying to apply that is getting messed up?

Jay
Washoe County GIS
0 Kudos
AndrewBowne
Occasional Contributor III

HI Jay,

Yes - the dynamic text works just fine until I add some formatting tags like <FNT></FNT> or <BOL></BOL>

Displays As Intended:

Displays Incorrectly (Dynamic Text contains "&"):

Try adding some formatting tags to your dynamic text and see if you experience the same.

Thanks,

Andrew

0 Kudos
TomBole
Esri Regular Contributor

Hi Andrew, 

I'm not sure exactly what your workflow is, but you mention an attribute table.  If you are grabbing information from a table you may want to consider using Table dynamic text - see Add and modify dynamic text—ArcGIS Pro | Documentation (about a third of the way down the topic is Table dynamic text).  With Arcade - ArcGIS Arcade | ArcGIS for Developers - you can further customize your text.

For example, I have a table of world countries that has fields for both country name and continent and I want a dynamic text element that displays the country's name along with which continent the country is in formatted like "X is in Y". I can use a Table dynamic text element ("Table Attribute" from the "Dynamic Text" gallery on the ribbon provides access to your attribute) and use an Arcade expression to customize the text.

I'm far from being an Arcade expert, but there is lot you can do. Table dynamic text ("Table Attribute") also works with map series.

Inserting format tags within the dynamic element is not supported. You can place formatting tags around the dynamic tag. For example, here is a dynamic text element for the date the project was saved. You see static text - "Date Saved:" and a dynamic tag - "dateSaved".

If I want the date to be bold I can add formatting tags around the dynamic tag.

Here's how the element looks in Text View.

The dynamic part of the element is prefaced with "< dyn type=". Within this dynamic tag you see its parts - <dyn type="project" property="dateSaved" format="short|short"/>. This particular dynamic text element provides a format option.  This allows me an option to show only the date.

There is a limit to what you can do within a dynamic text tag. For more information on this, please see - Dynamic text tags—ArcGIS Pro | Documentation 

Hope this helps, 

Tom

0 Kudos
AndrewBowne
Occasional Contributor III

Hey Tom,

Ok - I think with your direction I was able to use Arcade to escape the "&" by inserting as Dynamic Text-->Table Attribute".  Here is where things get a bit misleading:

What I had done previously is insert an attribute by going to "Dynamic Text-->Map Series-->Attribute

Then from the dialog I selected the attribute I wanted to add to the layout:

What I have found is by going this route, there is no dialog to format the dynamic text.  It simply inserts the text "as-is".

HOWEVER....

If I insert dynamic text from a table attribute, The ability to insert formatting expressions (i.e. replace the "&" with the HTML equivalent) using Arcade is available:

I guess the moral of the story here is that there are two ways to do the same thing BUT only one provides the ability to modify the field values using Arcade.   

Tom Bole‌ - Is this something that should be addressed with ArcGIS Pro functionality?  It appears to be a bit misleading that one way you can use expressions and the other way you cannot. 

Thanks,

Andrew

TomBole
Esri Regular Contributor

Andrew, 

Yes, the story can be a bit confusing, but it is important to understand that these two dynamic text elements are not exactly the same. The Map Series (DDP) Attribute element is legacy functionality from ArcMap (Data Driven Pages) and only works with the index layer of a map series. Table Attribute dynamic text, however, can work with any table in the map and does not have to be part of a map series.

Although, as you state, the Map Series (DDP) Attribute is limited when compared to Table Attribute dynamic text, this "simple" text element satisfies many user requirements. Many users like the simplicity of this option - they just want to add an attribute value from the index layer without any changes. 

You're certainly welcome to add a suggestion to ArcGIS Ideas if you have suggestions on how this experience can be improved.

Thanks for the feedback, 

Tom

StephaneLefebvre
New Contributor III

Andrew,

Did you post the idea?

I was looking for the same thing when I found your post.

Why is there no $page.PAGE_INDEX ... or something like the $feature. class in Arcade?

Anyway, we need this!

Thanks!

0 Kudos
AndrewBowne
Occasional Contributor III

No I did not.  It seems like there is some disconnect between legacy and current functionality.  I'm not sure why they both exist or, why they function differently.  After all, they do the same thing however the "legacy" (DDP) elements are limited.  Why not just eliminate one?

0 Kudos