Skip to content

Commit

Permalink
Merge pull request #4 from Esri/update_clone_keywords_06_21_21
Browse files Browse the repository at this point in the history
Updates to clone & update_attachment_keywords notebooks. Resolves issue #2.
  • Loading branch information
Zachary-Sutherby committed Jul 23, 2021
2 parents a338c5b + 56ddb33 commit 06b1704
Show file tree
Hide file tree
Showing 4 changed files with 332 additions and 312 deletions.
30 changes: 25 additions & 5 deletions Clone Surveys/clone_surveys_from_one_organization_to_another.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"\n",
"The foundation of the workflow is the <a href='https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.ContentManager.clone_items' target=_blank>`clone_items()`</a> method in the ArcGIS API for Python. This is the infrastructure that allows us to clone surveys from a source organization to a target organization. Given the different content and item types, possible ArcGIS Enterprise and ArcGIS Online configurations, security considerations, and item dependencies, the `clone_items()` method aims to produce an exact duplicate of an item that retains all of its functionality.\n",
"\n",
"Please note that cloning relies on the sharing model to determine the items a user can clone. If a user can access an item, that user can clone it. However, a user can't create any items in the target organization if they don't have the appropriate privileges to create content. For more information, see <a href='https://doc.arcgis.com/en/arcgis-online/reference/roles.htm#ESRI_SECTION1_4FF9051EFB814C249AB26B0ACFF7C79F' target=_blank>User types, roles, and privileges for ArcGIS Online</a> or <a href='https://enterprise.arcgis.com/en/portal/latest/administer/windows/roles.htm#ESRI_SECTION1_4FF9051EFB814C249AB26B0ACFF7C79F' target=_blank>User types, roles, and privileges for ArcGIS Enterprise</a>.\n",
"Please note that cloning relies on the sharing model to determine the items a user can clone. The user specified in the source organization will need admin access to the content that will be cloned, and the user specified in the target organization will need the ability to create content in that organization.\n",
"\n",
"For more information on the `clone_items` method, see the ArcGIS API for Python <a href=\"https://developers.arcgis.com/python/guide/cloning-content/\" target=\"_blank\">Cloning content guide</a> and <a href=\"https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html?#arcgis.gis.ContentManager.clone_items\" target=\"_blank\">API reference</a>. "
]
Expand Down Expand Up @@ -183,6 +183,10 @@
" \n",
" for item in cloned_items:\n",
" if item.type == 'Form':\n",
" # Update the form item to ensure all resources are rebuilt\n",
" downloaded_item = item.download(file_name=item.id+'.zip')\n",
" item.update({}, downloaded_item)\n",
" os.remove(downloaded_item)\n",
" # Share the form item to the group\n",
" item.update(item_properties={'tags':'PrdEnv, PythonAPI'})\n",
" item.share(groups=shared_group.id)\n",
Expand Down Expand Up @@ -275,7 +279,7 @@
"source_item_with_data = survey_manager.get(\"65b0ce4cfa2145eb8ce90122e54029e6\")\n",
"survey_folder = source_item_with_data.properties['ownerFolder']\n",
"\n",
"usr = arcgis.gis.User(source,'NinjaGreen')\n",
"usr = arcgis.gis.User(source, source.users.me.username)\n",
"\n",
"full_folder = usr.folders\n",
"\n",
Expand Down Expand Up @@ -323,10 +327,18 @@
"# Clone items to the new folder\n",
"cloned_items = target.content.clone_items(items=fldr_items, folder=fldr['title']+\"_Python\")\n",
"print(*cloned_items, sep=\"\\n\")\n",
"print(\"Result feature count: \", cloned_items[0].layers[0].query(where='1=1', return_count_only=True))"
"print(\"Result feature count: \", cloned_items[0].layers[0].query(where='1=1', return_count_only=True))\n",
"\n",
"# Search for the cloned survey and update the form item to ensure all resources are rebuilt\n",
"search_clone_survey = target.content.search('title: '+source_item_with_data.properties['title']+' and owner: '+target.users.me.username,'Form')\n",
"cloned_survey = search_clone_survey[0]\n",
"download_survey = cloned_survey.download(file_name=cloned_survey.id+'.zip')\n",
"cloned_survey.update({},download_survey)\n",
"os.remove(download_survey)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -338,8 +350,16 @@
"- Clone fails with non-ASCII characters in service name.\n",
"- Cloning is limited to 1000 records.\n",
"- BUG-000136846 - The clone_items() method fails when attempting to clone a public hosted feature layer view hosted by another organization with the error message, \"User does not have permissions to access this service.\"\n",
"- Spaces in survey names can cause issues when cloning between organizations."
"- BUG-000141004 - ArcGIS API for Python clone_items() method isn’t re-creating the item info URL’s for surveys published from the web designer.\n",
" - The workaround is to download the survey from the target environment and immediatly update it using the file downloaded. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -358,7 +378,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.7.10"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 06b1704

Please sign in to comment.