ArcGIS 10.1+ lets you easily put dynamically populated text boxes in your print layouts. Doing so puts some text in the text element that looks something like this:
<dyn type="page" property="attribute" field="sampleTable.sampleAttribute"domainlookup="true"/>
It works fine for me when I have it just pulls from the index feature class. My problem is that I have data in other feature classes in the same database that need to be joined to the index layer so I can pull relevant attributes out of there and display them in other text elements. As soon as I join one of those feature classes to the index feature class the domain lookup no longer works regardless of what it is set to. That is to say I only get the coded values in my text elements. ESRI has logged this bug (#NIM104451), but I need a workaround sooner than when (if) they get around to fixing it.
My first thought was to use some python to take care of this, but it's getting more unwieldy the more I think about it. My general thought process is this:
- Make sure the text elements I want to use share the name of the domain they will pull from
- List layout elements
List domains in the database
- For every layout element, step through the domain list until the domain equals the element name
- Take the current element text (the coded value) and replace it with the equivalent description from the domain
I got this far in my code before thinking there has to be a more efficient way:
import arcpy mxd = samplemxd domains = arcpy.da.ListDomains("Database Connections\\database.sde") Elements = arcpy.listlayoutelements(mxd) For elem in Elements: for dmn in domains: if elem.name == dmn.name: coded_values = domain.codedValues for val, desc in coded_values.iteritems(): if val == !layer.attribute! elem.text = desc
Any ideas? I'm open to non-python ideas as well, in case there's something database side I can do.