Two questions related to labeling 1:M related records in ArcGIS 10.2.
I have successfully built an Advanced Label expression in Python to label records from a related table. I am currently working from a local file geodatabase as a datasource. I need to migrate my label expression to work with an enterprise geodatabase. Result of the label expression code should be as follows:
FacilityID (data from parent table)
RatedKVA (data from parent table)
EquipID1 (data from related table)
EquipID2 (data from related table - may not exist)
EqiupID3 (data from related table - may not exist)
Code:
def FindLabel( [GlobalID], [FACILITYID] , [RatedKVA] ):
strWhereClause = '"TransformerGlobalID" = \'{0}\''.format([GlobalID])
strpTable = "C:\GIS\ArcFMViewer\Data\ElectricArcFMViewer.gdb\TRANSFORMERUNIT"
cursor = arcpy.da.SearchCursor(strpTable, "EquipID", strWhereClause)
result = [FACILITYID] + "\n" + [RatedKVA] + "\n"
for row in cursor:
strLabel = str(row[0])
result += strLabel + "\n"
return result.rstrip()
Question 1: How do I point the code to find the object table in the SQL Server based geodatabase and not the local?
Question 2: This code works perfectly if there is only one EquipID related record. If there are two or three related EquipID records the feature fails to label. No error or "!", just no label at all. Code will label all related records if I remove the FacilityID and RatedKVA arguments (result = "" in code). I don't understand why this occurs.
Note: I do have a version of this working in VBScript as well if that makes a difference for the data connection to the enterprise geodatabase.
Thanks!