<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Help &amp;quot;Clone surveys from one organization to another&amp;quot; issues in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/help-quot-clone-surveys-from-one-organization-to/m-p/1500841#M70978</link>
    <description>&lt;P&gt;i'm trying to clone a Survey from one org to another, ive tried the guides here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/survey123/guide/clone-surveys-from-one-organization-to-another/" target="_blank"&gt;Clone surveys from one organization to another | ArcGIS Survey123&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/Survey123-tools/tree/main/Clone_Surveys" target="_blank"&gt;Survey123-tools/Clone_Surveys at main · Esri/Survey123-tools · GitHub&lt;/A&gt;&lt;/P&gt;&lt;P&gt;but it never actually copies the survey&lt;/P&gt;&lt;P data-unlink="true"&gt;i have also tried the "ArcGIS Assistant&amp;nbsp;"&lt;/P&gt;&lt;P data-unlink="true"&gt;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&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StuartMoore_0-1720002588379.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/108654i795B322F6C8B8607/image-size/medium?v=v2&amp;amp;px=400" role="button" title="StuartMoore_0-1720002588379.png" alt="StuartMoore_0-1720002588379.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;has anyone managed to clone their survey?&lt;/P&gt;&lt;P&gt;Stu&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jul 2024 10:32:25 GMT</pubDate>
    <dc:creator>StuartMoore</dc:creator>
    <dc:date>2024-07-03T10:32:25Z</dc:date>
    <item>
      <title>Help "Clone surveys from one organization to another" issues</title>
      <link>https://community.esri.com/t5/python-questions/help-quot-clone-surveys-from-one-organization-to/m-p/1500841#M70978</link>
      <description>&lt;P&gt;i'm trying to clone a Survey from one org to another, ive tried the guides here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/survey123/guide/clone-surveys-from-one-organization-to-another/" target="_blank"&gt;Clone surveys from one organization to another | ArcGIS Survey123&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/Survey123-tools/tree/main/Clone_Surveys" target="_blank"&gt;Survey123-tools/Clone_Surveys at main · Esri/Survey123-tools · GitHub&lt;/A&gt;&lt;/P&gt;&lt;P&gt;but it never actually copies the survey&lt;/P&gt;&lt;P data-unlink="true"&gt;i have also tried the "ArcGIS Assistant&amp;nbsp;"&lt;/P&gt;&lt;P data-unlink="true"&gt;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&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StuartMoore_0-1720002588379.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/108654i795B322F6C8B8607/image-size/medium?v=v2&amp;amp;px=400" role="button" title="StuartMoore_0-1720002588379.png" alt="StuartMoore_0-1720002588379.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;has anyone managed to clone their survey?&lt;/P&gt;&lt;P&gt;Stu&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2024 10:32:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-quot-clone-surveys-from-one-organization-to/m-p/1500841#M70978</guid>
      <dc:creator>StuartMoore</dc:creator>
      <dc:date>2024-07-03T10:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: Help "Clone surveys from one organization to another" issues</title>
      <link>https://community.esri.com/t5/python-questions/help-quot-clone-surveys-from-one-organization-to/m-p/1500892#M70980</link>
      <description>&lt;P&gt;code being ran:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# 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&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;---------------------------------------------------------------------------
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:
-&amp;gt; 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
-&amp;gt; 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:
-&amp;gt; 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 &amp;lt;cell line: 0&amp;gt;()
     18 
     19     # Clone all items to the new folder in target environment
---&amp;gt; 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         )
-&amp;gt; 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             &amp;gt; 0
   1327         ):
-&amp;gt; 1328             return self._clone_synchronous()
   1329         # elif len([node for node in self._graph.values() if isinstance(node, _StoryMapDefinition)]) &amp;gt; 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()
-&amp;gt; 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:
-&amp;gt; 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:
-&amp;gt; 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'", &amp;lt;Item title:"Valve Survey App V2 Blank" type:Form owner:Stuart.Moore@cadentgas.com_CadentFSM&amp;gt;)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2024 11:49:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-quot-clone-surveys-from-one-organization-to/m-p/1500892#M70980</guid>
      <dc:creator>StuartMoore</dc:creator>
      <dc:date>2024-07-03T11:49:23Z</dc:date>
    </item>
  </channel>
</rss>

