I am trying to assign labels to feature layer using advance python labeling.
The label are fetching from feature layer related table using following python script logic, which is given at ESRI Tech Support How To: Label a related table
def FindLabel ([keyField], [FirstLabel]):
key1 = [keyField] # Key field in feature class
key2 = "ID" # Key field in related table
L = [FirstLabel] # Label field in feature class
L2 = "Label2" # Label field in related table
myDataTable = r"<path-to-related-table>" # Path to related table
cur = arcpy.da.SearchCursor(myDataTable, [key2, L2])
for row in cur:
if str(key1) == str(row):
L = L + " " + str(row)
I can see the labels in ArcMap or in the preview before I publish it as a web service, but cannot see them in ArcGIS Online. I suspect there might be a problem with the path I use in the label expression.
It looks something like this: r"Database Connections\TEST.sde\Related_Table". Am I missing something?
Also, I have created a brand new geodatabe, where I put a feature class and a related table I want to get the labels from. In this case my paths looks like that - r"C:\Test.gdb\Related_Table". Again, it works fine in ArcMap, but there are no labels after I have published it as a web service?
Thanks heaps in advance!