Relationship class fields

391
5
08-31-2020 11:42 AM
BillChappell
Occasional Contributor II

I've create relationship classes but they want to see specific fields as the attribute index. .i.e. See yellow highlighted text. In my case I have points and have about 10 Relationship class tables. They all seem to work properly, but for each attribute table the field value it's showing under "Attributes from xxx" is coming from different fields.  How do I specify which field to use? I'm using a script to create these and the tables are  related all on the same field names. Is there a way to set the fields it uses for this? 

Attribute links

I'm using python to create these, here is my code:

tables = arcpy.ListTables()
for i in tables:
    if (i != 'Structure'):
        print(i)

         tab = i
         relClass = i+"_rc"
         forLabel = "Attributes from Table"
         backLabel = "Attributes from " + i
         foreignKey = "equipment_number"
         primaryKey = "PARENT_EQUIPMENT_NUMBER"


         arcpy.CreateRelationshipClass_management(tab,
                                                                                  "StructurePts",
                                                                                  relClass,
                                                                                  "SIMPLE",
                                                                                  forLabel,
                                                                                  backLabel,
                                                                                  "NONE",
                                                                                   "ONE_TO_MANY",
                                                                                  "NONE",
                                                                                  primaryKey,
                                                                                  foreignKey)

0 Kudos
5 Replies
BillChappell
Occasional Contributor II
0 Kudos
BillChappell
Occasional Contributor II

My mistake, you need to add all the tables into ArcMap, Right-click Display, pick the Field, for each table. So it's stored in the MXD somewhere, can you hit this with Python?

0 Kudos
JoeBorgione
MVP Esteemed Contributor

There are a couple of things that are confusing to me: first, a relationship class is database object so you would get to it that way, not through an MXD.  Second, it looks like the 'Attributes From Anchor' are named with numbers at the beginning, so I'm very curious how you've been able to get away with that. (see FAQ: What characters should not be used in ArcGIS for field names and table names? )

That should just about do it....
0 Kudos
BillChappell
Occasional Contributor II

Hope this helps. The map uses the tables in the MXD, the relationship class manages the relationship between the feature and the other tables. So in a Map doc (mxd) you can set the primary display field to use when you identify. I noticed in the relationship it was showing the related records but that number you see was an attribute value for the field it was using. If I went to the table, set it to display the primary display field, it showed the value for my field, which made more sense to me. Now if I clicked on this value, in the bottom part of the identify dialog, it showed the other fields and attribute values. 

0 Kudos
JoeBorgione
MVP Esteemed Contributor

So in a Map doc (mxd) you can set the primary display field to use when you identify.

Okay, gotcha.  I'm not using mxd's anymore so I'm no help there. It looks like someone had a similar need some time ago:  https://community.esri.com/ideas/4647 

That should just about do it....
0 Kudos