How does ArcMap decide which field is used for the display expression

545
4
11-21-2017 06:12 AM
Highlighted
Occasional Contributor

I have several csv files that are updated by an external organization on a nightly basis. The records from one csv file are used to geocode and create a point FC with python in a fGDB. I can add the csv and point FC to ArcMap and create a Relate in the Properties dialog of the feature class to each of the tables. The end users will then use the Identify tool to inspect features in their zones. When the relationships are expanded, they would like to see values from specific fields so if they want to drill down and see the related records, they can see what they want without having to click on every related record. Instead, they see useless information or sometimes, just a "-1".

I have told them about bringing the tables into ArcMap and setting the Display Expression in the table properties. This works in that MXD only. They want to have a .lyr file that they can drag and drop into a new MXD and see the pertinent info. I've tried creating the other tables in the fGDB and creating Relationships there but can not control what is shown in the identify window. 

 

These are crime analysts and this is part of their morning routine. Doing their task quickly and efficiently is key. Any ideas?

identify window

Tags (1)
Reply
0 Kudos
4 Replies
Highlighted
Occasional Contributor

From:

Understanding the display expression for a field—Help | ArcGIS for Desktop 

The display expression defaults to the first field of string type that contains the text name (case insensitive) in the field name. If no name field exists, the display field defaults to the first field of string type, then the first field of integer type, then the first field of any type. You can change the field used in the display expression on the Display tab of the Layer Properties or Table Properties dialog box.

I'll try this and see if I can get the results we want.

Highlighted
Occasional Contributor

So... 

I ensured that the ArrestingOfficerName is just ArrestingOfficer and the first field in the csv is my string field with the data I want to see. I then dragged the csv into arcmap and made the Relate, the display expression is set correctly in the identify window. However, if I create a relate to that same table without bringing it into arcmap, I still get the wrong info in the identify window. I tried exporting the csv table into the fGDB and when I set up the relate without bringing into arcmap, the display expression is the OBJECTID.

So it seems that the behavior described in the link I posted is only true if the FC or table is brought into arcmap. Not if it is referenced externally in the csv or fGDB.

I suppose I can create a button in their Add-In we developed that will add the data and create the relate automatically. It just seems that there should be a way to determine the display expression for external tables.

HELP!

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

I suppose I can create a button in their Add-In we developed that will add the data and create the relate automatically. It just seems that there should be a way to determine the display expression for external tables.

Unfortunately the display field is not exposed in arcpy.mapping. Are you using Python addins?

Layer—Help | ArcGIS Desktop 

If these csv files are updated in-place every night, maybe if these paths can be set up (or copied to) a standard place, you can just add the .lyr ArcMap with your relates and display fields all set up and it will just work. You could tweak the .lyr file just so to hide fields that aren't useful to the user, set up symbology etc. ahead of time.

In arcpy.mapping often things that aren't exposed can be implemented by setting up a .lyr or .mxd with the properties all set up, and you can just change the source in arcpy.mapping if you have to. 

Highlighted
Occasional Contributor

Then its a good thing I'm using ArcObjects for the addin. I wrote code to add a new point fc, tables, and a function to add the relationships. I tried to keep the two systems apart, but they said it was ok to put them in the same place. This allowed me to be able to set def queries, relationships and change source csv files with radio buttons and check boxes.

The relationships were tricky to figure out.

    Public Function createRelationsip(ByVal pTable As ITable, ByVal strJnFieldTbl As String, ByVal pLayer As IFeatureLayer, ByVal strJnFieldLyr As String, ByVal relName As String, ByVal fwdLabel As String, ByVal card As esriRelCardinality) As IRelationshipClass
        Dim pMemRelFact As IMemoryRelationshipClassFactory = New MemoryRelationshipClassFactory()
        Dim pTableOC As IObjectClass = pTable
        Dim pLayerOC As IObjectClass = pLayer.FeatureClass
        Dim pRelClass As IRelationshipClass = pMemRelFact.Open(relName, pTableOC, strJnFieldTbl, pLayerOC, strJnFieldLyr, fwdLabel, "backward", esriRelCardinality.esriRelCardinalityOneToMany)
        Dim pRelClassCollEdit As IRelationshipClassCollectionEdit = CType(pLayer, IRelationshipClassCollectionEdit)
        pRelClassCollEdit.AddRelationshipClass(pRelClass)
        Return pRelClass
    End Function
‍‍‍‍‍‍‍‍‍

    Public Sub removeRelationship(ByVal pLayer As IFeatureLayer, ByVal relClass As IRelationshipClass)
        Dim pRelClassCollEdit As IRelationshipClassCollectionEdit = CType(pLayer, IRelationshipClassCollectionEdit)
        pRelClassCollEdit.RemoveRelationshipClass(relClass)
    End Sub‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

  ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍