i'm trying to clone a Survey from one org to another, ive tried the guides here:
Clone surveys from one organization to another | ArcGIS Survey123
Survey123-tools/Clone_Surveys at main · Esri/Survey123-tools · GitHub
but it never actually copies the survey
i have also tried the "ArcGIS Assistant "
the survey isnt that complicated its a point feature layer and 10 related tables, each has no more than 10,000 records (most have 1000 to 5000) including attachments
has anyone managed to clone their survey?
Stu
code being ran:
# Create new group in the target environment
#shared_group = target.groups.create(title=group.title, tags=group.tags)
# Clone source items to the target environment
for form_item in sourceForms:
    # Obtain the feature service associated with the survey
    related_items = form_item.related_items('Survey2Service','forward')
    # Obtain the additional items that have a relationship with the survey
    additional_items = form_item.related_items('Survey2Data','forward')
    all_items = [form_item] + related_items + additional_items
    print("Source items: ", *all_items, sep="\n")
    
    # Create new folder according to survey name 
    title = form_item.title.replace(" ", "_")
    folderName = "Survey-" + title
    target.content.create_folder(folderName)
    
    # Clone all items to the new folder in target environment
    cloned_items = target.content.clone_items(items=all_items, folder=folderName, copy_data=False)
    
    # Check the feature count in cloned feature layer. Feature count should 0 because existing data is not copied
    try:
        print("Result feature count: ", cloned_items[0].layers[0].query(where='1=1', return_count_only=True))
    except:
        print("error with counts")
    
    for item in cloned_items:
        if item.type == 'Form':
            # Update the form item to ensure all resources are rebuilt
            downloaded_item = item.download(file_name=item.id+'.zip')
            item.update({}, downloaded_item)
            os.remove(downloaded_item)
            # Share the form item to the group
            item.update(item_properties={'tags':'Valve Survey blank'})
            #item.share(groups=shared_group.id)
            # Share source feature service to group
            source_fs = item.related_items('Survey2Service','forward')[0]
            source_fs.update(item_properties={'tags':'Valve Survey blank'})
            #source_fs.share(groups=shared_group.id)
        else:
            pass
Error:
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/opt/conda/lib/python3.11/site-packages/arcgis/_impl/common/_clone.py in update_form(self, target, new_item, clone_mapping)
   5406                 if related_item in service_related:
-> 5407                     new_id = clone_mapping["Services"][related_item["url"]]["id"]
   5408                     feature_service = target.content.get(new_id)
KeyError: 'https://services3.arcgis.com/Ee____hzcB/arcgis/rest/services/service_8a209f____e6cf8/FeatureServer'
During handling of the above exception, another exception occurred:
Exception                                 Traceback (most recent call last)
/opt/conda/lib/python3.11/site-packages/arcgis/_impl/common/_clone.py in clone(self)
   5162                 original_item = self.info
-> 5163                 self.update_form(self.target, new_item, self._clone_mapping)
   5164             else:
/opt/conda/lib/python3.11/site-packages/arcgis/_impl/common/_clone.py in update_form(self, target, new_item, clone_mapping)
   5446         except Exception as ex:
-> 5447             raise Exception(
   5448                 "Failed to update {0} {1}: {2}".format(
Exception: Failed to update Form Valve Survey App V2 Blank: 'https://services3.arcgis.com/Ee____hzcB/arcgis/rest/services/service_8a209f____e6cf8/FeatureServer'
During handling of the above exception, another exception occurred:
_ItemCreateException                      Traceback (most recent call last)
/tmp/ipykernel_36/3848405123.py in <cell line: 0>()
     18 
     19     # Clone all items to the new folder in target environment
---> 20     cloned_items = target.content.clone_items(items=all_items, folder=folderName, copy_data=False)
     21 
     22     # Check the feature count in cloned feature layer. Feature count should 0 because existing data is not copied
/opt/conda/lib/python3.11/site-packages/arcgis/gis/__init__.py in clone_items(self, items, folder, item_extent, use_org_basemap, copy_data, copy_global_ids, search_existing_items, item_mapping, group_mapping, owner, preserve_item_id, **kwargs)
   8758             wab_code_attach=kwargs.pop("copy_code_attachment", True),
   8759         )
-> 8760         return deep_cloner.clone()
   8761 
   8762     def bulk_update(
/opt/conda/lib/python3.11/site-packages/arcgis/_impl/common/_clone.py in clone(self)
   1326             > 0
   1327         ):
-> 1328             return self._clone_synchronous()
   1329         # elif len([node for node in self._graph.values() if isinstance(node, _StoryMapDefinition)]) > 0:
   1330         #    return self._clone_synchronous()
/opt/conda/lib/python3.11/site-packages/arcgis/_impl/common/_clone.py in _clone_synchronous(self)
   1219                     if item:
   1220                         item.delete()
-> 1221                 raise ex
   1222 
   1223         return [i for i in self._get_created_items() if isinstance(i, arcgis.gis.Item)]
/opt/conda/lib/python3.11/site-packages/arcgis/_impl/common/_clone.py in _clone_synchronous(self)
   1201             for node in leaf_nodes:
   1202                 try:
-> 1203                     node.clone()
   1204                 except _ItemCreateException as ex:
   1205                     exceptions.append(ex)
/opt/conda/lib/python3.11/site-packages/arcgis/_impl/common/_clone.py in clone(self)
   5175 
   5176         except Exception as ex:
-> 5177             raise _ItemCreateException(
   5178                 "Failed to create {0} {1}: {2}".format(
   5179                     original_item["type"], original_item["title"], str(ex)
_ItemCreateException: ("Failed to create Form Valve Survey App V2 Blank: Failed to update Form Valve Survey App V2 Blank: 'https://services3.arcgis.com/Ee____hzcB/arcgis/rest/services/service_8a209f____e6cf8/FeatureServer'", <Item title:"Valve Survey App V2 Blank" type:Form owner:Stuart.Moore@cadentgas.com_CadentFSM>)