Hi Xander,
I'm working with this code sample in 10.2 to access related information from downloaded attachments. The first problem I'm running into is that my myFeatureClass_ATTACH has no REL_OBJECTID field, only a REL_GLOBALID field. When I adjust the code to use the expression to match the global id's instead of the object id's, I'm getting the following error:
I'm not sure why it's still trying to select OBJECTID, which is maybe the problem (?) -- anyway, see my modified code below. Please let me know if you have any ideas. Any guidance is much appreciated! Thanks -
Trill
def main():
global arcpy
import arcpy, os
# fixed settings
fldBLOB = 'DATA'
fldAttName = 'ATT_NAME'
fldRelGID = 'REL_GLOBALID'
# your settings (edit these)
## related feature class
fc = r"C:\Forstmobil_2014.12.01\Geodaten\Forstmobil_2014.12.01.gdb\Baumkontrolle_AGS_online"
## attachment table
tbl = r"C:\Forstmobil_2014.12.01\Geodaten\Forstmobil_2014.12.01.gdb\Baumkontrolle_AGS_online__ATTACH
fldRelatedInfo = 'CreationDate' # should be valid column in FC
with arcpy.da.SearchCursor(tbl,[fldBLOB,fldAttName,fldRelGID]) as cursor:
for row in cursor:
binaryRep = row[0]
fileName = row[1]
relGID = row[2]
# access related information
myRelatedInfo = QueryRelatedData(fc, fldRelatedInfo, relGID)
print myRelatedInfo
def QueryRelatedData(fc, fldRelatedInfo, relGID):
fldGID = 'GlobalID'
expression = arcpy.AddFieldDelimiters(fc, fldGID) + " = {0}".format(relGID)
with arcpy.da.SearchCursor(fc, (fldGID, fldRelatedInfo), where_clause=expression) as cursor:
for row in cursor:
return row[1]
break
del row
if __name__ == '__main__':
main()