<?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 Re: Overwrite Feature Layer from ArcGIS Pro to ArcGIS Online using arcpy in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/overwrite-feature-layer-from-arcgis-pro-to-arcgis/m-p/1134949#M50177</link>
    <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank"&gt;Code formatting ... the Community Version - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;would help to provide line numbers and code syntax highlights&lt;/P&gt;&lt;P&gt;you collect values, then joining all of them, so you have an indentation issue, format the code and see if the join is occurring inside or outside the collection loop&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jan 2022 14:24:15 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2022-01-19T14:24:15Z</dc:date>
    <item>
      <title>Overwrite Feature Layer from ArcGIS Pro to ArcGIS Online using arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/overwrite-feature-layer-from-arcgis-pro-to-arcgis/m-p/1134937#M50174</link>
      <description>&lt;P&gt;Hello everybody!&lt;/P&gt;&lt;P&gt;I would like to overwrite several layers from ArcGIS Pro to ArcGIS Online using arcpy. The layer names in ArcGIS Online and Pro are completly different from each other.&lt;/P&gt;&lt;P&gt;My idea was to assign the new layer in ArcGIS Pro with the old layer in ArcGIS Online via a dictionary. But I dont know how to proceed...&lt;/P&gt;&lt;P&gt;Could you please help me with that?&lt;/P&gt;&lt;P&gt;I'm very new to scripting. I used a lot from &lt;A href="https://github.com/rooschu/overwrite-web-layers/blob/master/OverwriteWebLayers.py" target="_blank" rel="noopener"&gt;https://github.com/rooschu/overwrite-web-layers/blob/master/OverwriteWebLayers.py&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/2.8/arcpy/sharing/featuresharingdraft-class.htm" target="_blank" rel="noopener"&gt;https://pro.arcgis.com/en/pro-app/2.8/arcpy/sharing/featuresharingdraft-class.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My script so far is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;LI-CODE lang="python"&gt;prjFolder = r"path"
prjPath = os.path.join(prjFolder, r"path to .aprx")

# Set login credentials 
portal = "..."  
user = "XXX"
password = "XXX"

# Assign name and location for temporary staging files
tempPath = prjFolder

#select layers in arcgis pro
layers = geoMap.listLayers()
service_name = []
for x in layers:
    service_name.append(x.name)

#sharing draft
stringdraft = ".sddraft"
sddraft_filename = [x + stringdraft for x in service_name]
sddraft = os.path.join(tempPath, *sddraft_filename)
#sharing sd
stringsd = ".sd"
sd_filename = [x + stringsd for x in service_name]
sd = os.path.join(tempPath, *sd_filename)

# Connect to ArcGIS online
print("Connecting to {}".format(portal))
gis = GIS(portal, user, password)
print("Successfully logged in as: " + gis.properties.user.username + "\n")

# Assign environment and project, and create empty dictionaries
arcpy.env.overwriteOutput = True
prj = arcpy.mp.ArcGISProject(prjPath)
layerDict = {}
servDict = {}

# Populate map dictionary with map names and objects from earlier defined project
for layer in geoMap.listLayers ():
    layerDict[layer.name] = layer


#select ArcGIS Online Web Layers
lyItems = gis.content.search(query="owner:{0}".format(user),item_type="Feature Layer", max_items=100)
ext= ["WFL1", "_Faelle", "genschaft"]
service_name = [item for item in lyItems if item.title.endswith(tuple(ext))]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also when I try to create the both os.path.join() it doesn't create six diferent paths but one very long path with all my layers added.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 15:30:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/overwrite-feature-layer-from-arcgis-pro-to-arcgis/m-p/1134937#M50174</guid>
      <dc:creator>Alice</dc:creator>
      <dc:date>2022-01-19T15:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite Feature Layer from ArcGIS Pro to ArcGIS Online using arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/overwrite-feature-layer-from-arcgis-pro-to-arcgis/m-p/1134949#M50177</link>
      <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank"&gt;Code formatting ... the Community Version - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;would help to provide line numbers and code syntax highlights&lt;/P&gt;&lt;P&gt;you collect values, then joining all of them, so you have an indentation issue, format the code and see if the join is occurring inside or outside the collection loop&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 14:24:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/overwrite-feature-layer-from-arcgis-pro-to-arcgis/m-p/1134949#M50177</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-01-19T14:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite Feature Layer from ArcGIS Pro to ArcGIS Online using arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/overwrite-feature-layer-from-arcgis-pro-to-arcgis/m-p/1134978#M50180</link>
      <description>&lt;P&gt;thanks for the replay. I changed the code&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 15:33:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/overwrite-feature-layer-from-arcgis-pro-to-arcgis/m-p/1134978#M50180</guid>
      <dc:creator>Alice</dc:creator>
      <dc:date>2022-01-19T15:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite Feature Layer from ArcGIS Pro to ArcGIS Online using arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/overwrite-feature-layer-from-arcgis-pro-to-arcgis/m-p/1134999#M50184</link>
      <description>&lt;P&gt;As I suspected.&amp;nbsp; By example compare your results to this example&lt;/P&gt;&lt;LI-CODE lang="python"&gt;tempPath = r"c:\folder"
tempPath
'c:\\folder'

service_name = ['a', 'b', 'c', 'd']
stringsd = ".sd"
sd_filename = [x + stringsd for x in service_name]
sd = os.path.join(tempPath, *sd_filename)
sd
'c:\\folder\\a.sd\\b.sd\\c.sd\\d.sd'  # -- your output

for nme in sd_filename:
    sd = os.path.join(tempPath, nme)
    print(sd)
# --- my output
c:\folder\a.sd
c:\folder\b.sd
c:\folder\c.sd
c:\folder\d.sd&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 19 Jan 2022 16:12:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/overwrite-feature-layer-from-arcgis-pro-to-arcgis/m-p/1134999#M50184</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-01-19T16:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite Feature Layer from ArcGIS Pro to ArcGIS Online using arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/overwrite-feature-layer-from-arcgis-pro-to-arcgis/m-p/1135324#M50237</link>
      <description>&lt;P&gt;Thank you very much! It works! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jan 2022 07:03:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/overwrite-feature-layer-from-arcgis-pro-to-arcgis/m-p/1135324#M50237</guid>
      <dc:creator>Alice</dc:creator>
      <dc:date>2022-01-20T07:03:15Z</dc:date>
    </item>
  </channel>
</rss>

