Select to view content in your preferred language

Unable to insert rows into a M-N relationship table via arcpy script

160
0
yesterday
ArshiyaNisa
Occasional Contributor

We are trying to insert rows into a many to many relationship table via arcpy script. Attempting to write new rows with insertcursor causes an error. Manually adding data to relationship table works fine.

RuntimeError: Message: Unable to complete operation.
Details: Internal error during object insert. Invalid foreign key value

We have checked the following things-

  1. GlobalIDs existing in both the parent tables.
  2. GlobalIDs are valid.

Below is the sample snippet of code-

aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.activeMap

mc_guid = '{0196792F-17E7-4A17-A2E4-0B381C407A30}'
ls_guid = '{5FB63569-5792-42H7-AAA9-3E7A912F3226}'
lsmc_rel = m.listTables("R_Table1_Table2)[0]

with arcpy.da.InsertCursor(lsmc_rel, ['T1_GlobalID', 'T2_GlobalID']) as cursor:
cursor.insertRow((mc_guid, ls_guid))

Version details- 

Enterprise Version- 11.5

ArcGIS Pro- 3.5

 

 

 

 

0 Kudos
0 Replies