AnsweredAssumed Answered

KeyError: 'attachmentGroups' when cloning forms and associated hosted feature services

Question asked by jgustine on May 10, 2018
Latest reply on Sep 4, 2018 by chris_fox-esristaff

Pretty simple cloning operation here. Just want to test cloning Survey123 forms and there associated feature service

 

from arcgis import GIS
from arcgis.mapping import WebMap
import arcpy
from arcpy import env


#set portal and define resources

source = GIS('https://source.southernute.com/portal', "admin", "password")
target = GIS('https://target.southernute.com/portal', "admin", "password")

print (source)
print (target)

##get source info
#sourceItem = source.content.search('owner:arcgisportaladmin',item_type = "Form", max_items=500)

sourceItem = source.content.get('f0979f620b30416db90bf6d0de5d2866')

print (sourceItem)

target.content.create_folder(("Survey-"+sourceItem.title).rstrip())

f = ("Survey-"+sourceItem.title).rstrip()

print ('cloning...')
clone = target.content.clone_items([sourceItem], folder=f, copy_data=True)

Keep getting this error? It happens on forms with and without attachments? Any ideas?

Traceback (most recent call last):
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\_impl\common\_clone.py", line 1629, in clone
self._add_features(new_layers, relationships, layer_field_mapping, feature_service.properties['spatialReference'])
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\_impl\common\_clone.py", line 1130, in _add_features
attachments = original_attachment_manager.search()
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\managers.py", line 153, in search
for result in results['attachmentGroups']:
KeyError: 'attachmentGroups'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\source\code\admin\clonetest.py", line 32, in <module>
clone = target.content.clone_items([sourceItem], folder=f, copy_data=True)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py", line 3121, in clone_items
return deep_cloner.clone()
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\_impl\common\_clone.py", line 525, in clone
results = loop.run_until_complete(self._clone(executor))
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\asyncio\base_events.py", line 467, in run_until_complete
return future.result()
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\_impl\common\_clone.py", line 510, in _clone
raise result
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\concurrent\futures\thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\_impl\common\_clone.py", line 1638, in clone
raise _ItemCreateException("Failed to create {0} {1}: {2}".format(original_item['type'], original_item['title'], str(ex)), new_item)
arcgis._impl.common._clone._ItemCreateException: ("Failed to create Feature Service SUU - Confined Space Reclassification Certificate\n: 'attachmentGroups'", <Item title:"SUU - Confined Space Reclassification Certificate
" type:Feature Layer Collection owner:arcgisportaladmin>)

Outcomes