<?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: Share as Route Layer ignoring my output folder in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/share-as-route-layer-ignoring-my-output-folder/m-p/1595618#M73916</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/787793"&gt;@AndreaStaten&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;This could be a possible bug.&amp;nbsp; You could try adding additional code to move the layer after it's created.&amp;nbsp; For example, add a variable and print statement after the following line to see what's returned in the string:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Share the route as a route layer
result = arcpy.na.ShareAsRouteLayers(route_layer, route_layer_name, output_folder)
print(result)&lt;/LI-CODE&gt;&lt;P&gt;If the item ID is returned, you could move the layer with the following:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

# Connect to Portal
gis = GIS("https://gis.issue.com/issuegisportal", "admin", "Password123")

# Move item
item = gis.content.get(item_id)
item.move('Meter')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Mar 2025 15:36:53 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2025-03-14T15:36:53Z</dc:date>
    <item>
      <title>Share as Route Layer ignoring my output folder</title>
      <link>https://community.esri.com/t5/python-questions/share-as-route-layer-ignoring-my-output-folder/m-p/1595179#M73905</link>
      <description>&lt;P&gt;I am scripting the process of creating routes for some of our crew members. I have come across a problem where I assign a value for the output_folder and it is essentially ignored and just shares it directly to my content.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code, some of it has been edited to remove sensitive information:&lt;/P&gt;&lt;P&gt;# This renames the name field in the Route Layer and shares it online. It is supposed to share it to the Meter folder but this part is not working right now.&lt;BR /&gt;Date3 = time.strftime("%m%d")&lt;/P&gt;&lt;P&gt;try:&lt;BR /&gt;# Set the active portal&lt;BR /&gt;arcpy.SignInToPortal("&lt;A href="https://gis.issue.com/issuegisportal" target="_blank"&gt;https://gis.issue.com/issuegisportal&lt;/A&gt;", "admin", "Password123")&lt;/P&gt;&lt;P&gt;# Reference the current project and map&lt;BR /&gt;project = arcpy.mp.ArcGISProject("CURRENT")&lt;BR /&gt;map = project.listMaps("Map")[0] # Adjust "Map" to the name of your map if different&lt;/P&gt;&lt;P&gt;# Find the route layer in the Contents pane&lt;BR /&gt;route_layer = None&lt;BR /&gt;for layer in map.listLayers():&lt;BR /&gt;if layer.name == "Route_MetersToRead": # Replace with the name of your route layer&lt;BR /&gt;route_layer = layer&lt;BR /&gt;break&lt;/P&gt;&lt;P&gt;if route_layer is None:&lt;BR /&gt;raise Exception("Route layer not found in the Contents pane")&lt;/P&gt;&lt;P&gt;route_layer_path = f"S:\Meter Route\MeterRoute\MeterRoute.gdb\Routes1m31w84"&lt;/P&gt;&lt;P&gt;# Update the 'Name' field values&lt;BR /&gt;with arcpy.da.UpdateCursor(route_layer_path, ["Name"]) as cursor:&lt;BR /&gt;for row in cursor:&lt;BR /&gt;row[0] = f"Route_MetersToRead_{Date3}" # Replace with the new name you want&lt;BR /&gt;cursor.updateRow(row)&lt;/P&gt;&lt;P&gt;print("Field 'Name' updated successfully.")&lt;/P&gt;&lt;P&gt;# Define the output route layer name and folder&lt;BR /&gt;route_layer_name = f"Route_MetersToRead_{Date3}"&lt;BR /&gt;output_folder = 'Meter'&lt;BR /&gt;# Share the route as a route layer&lt;BR /&gt;arcpy.na.ShareAsRouteLayers(route_layer, route_layer_name, output_folder)&lt;/P&gt;&lt;P&gt;# Check if the route layer was shared successfully&lt;BR /&gt;print("Route layer shared successfully.")&lt;/P&gt;&lt;P&gt;except Exception as e:&lt;BR /&gt;print(f"An error occurred: {e}")&lt;BR /&gt;arcpy.AddError(str(e))&lt;/P&gt;&lt;P&gt;Also worth noting, I 100% have access and privileges to share to this folder, as I can manually do it. I also have tried scripting it to export to other folders and it is still ignored, so it is not a specific issue with this folder.&lt;/P&gt;&lt;P&gt;Any ideas what could be causing this?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 15:02:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/share-as-route-layer-ignoring-my-output-folder/m-p/1595179#M73905</guid>
      <dc:creator>AndreaStaten</dc:creator>
      <dc:date>2025-03-13T15:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Share as Route Layer ignoring my output folder</title>
      <link>https://community.esri.com/t5/python-questions/share-as-route-layer-ignoring-my-output-folder/m-p/1595618#M73916</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/787793"&gt;@AndreaStaten&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;This could be a possible bug.&amp;nbsp; You could try adding additional code to move the layer after it's created.&amp;nbsp; For example, add a variable and print statement after the following line to see what's returned in the string:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Share the route as a route layer
result = arcpy.na.ShareAsRouteLayers(route_layer, route_layer_name, output_folder)
print(result)&lt;/LI-CODE&gt;&lt;P&gt;If the item ID is returned, you could move the layer with the following:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

# Connect to Portal
gis = GIS("https://gis.issue.com/issuegisportal", "admin", "Password123")

# Move item
item = gis.content.get(item_id)
item.move('Meter')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2025 15:36:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/share-as-route-layer-ignoring-my-output-folder/m-p/1595618#M73916</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2025-03-14T15:36:53Z</dc:date>
    </item>
  </channel>
</rss>

