<?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: Using a feature service as GP tool input in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-a-feature-service-as-gp-tool-input/m-p/1303756#M68051</link>
    <description>&lt;P&gt;Well I've learned two things today then! I didn't realise the "Save" method existed for feature sets in the ArcGIS API for Python, that seems very useful! Glad you've managed to find a solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jun 2023 05:36:13 GMT</pubDate>
    <dc:creator>JoshuaSharp-Heward</dc:creator>
    <dc:date>2023-06-28T05:36:13Z</dc:date>
    <item>
      <title>Using a feature service as GP tool input</title>
      <link>https://community.esri.com/t5/python-questions/using-a-feature-service-as-gp-tool-input/m-p/1303708#M68048</link>
      <description>&lt;P&gt;Hi brains trust. I'm writing a python script that uses a feature service (table) as an input for an Export Table tool. I have the code working perfectly on my PC but not on the server where I intend to schedule it. They are running the same versions of Pro and python. The code is below, along with the error I'm getting. Is there a better way to do this (like I mentioned, this works fine on my PC).&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Variables - update these lines
SPDRoutes = "https://services3.arcgis.com/1GMgEwgl0qHnrBQf/arcgis/rest/services/Distances_Table/FeatureServer/0" # Feature service containing routes to be updated

import arcpy, time, os

# Overwrite Output
arcpy.env.overwriteOutput = True

import keyring
pw = keyring.get_password("ArcGISOnline", "MyUserName")
arcpy.SignInToPortal("https://fpcwa.maps.arcgis.com", "MyUserName", pw)
print("Connected to the GIS")

# Create temporary FGDB
sdproutesgdb = arcpy.CreateFileGDB_management(arcpy.env.scratchFolder, "sdproutes")
print ("Temp FGDB created")

arcpy.env.workspace = arcpy.env.scratchFolder + "\\sdproutes.gdb"
print ("Workspace set to temp FGDB")

# Compare existing SDP Routes to Updated SDP Harvest Plan
ExistingSDPRoutes = arcpy.conversion.ExportTable(
    in_table = SPDRoutes,
    out_table = arcpy.env.workspace + "\\ExistingSDPRoutes",
    where_clause = "",
    use_field_alias_as_name = "NOT_USE_ALIAS",
    field_mapping = 'Name "Name" true true false 1024 Text 0 0,First,#,Plantation SDP Route Distances,Name,0,1024;Total_Length "Total_Length" true true false 0 Double 0 0,First,#,Plantation SDP Route Distances,Total_Length,-1,-1;GlobalID "GlobalID" false false true 38 GlobalID 0 0,First,#,Plantation SDP Route Distances,GlobalID,-1,-1;CreationDate "CreationDate" false true true 8 Date 0 0,First,#,Plantation SDP Route Distances,CreationDate,-1,-1;Creator "Creator" false true true 128 Text 0 0,First,#,Plantation SDP Route Distances,Creator,0,128;EditDate "EditDate" false true true 8 Date 0 0,First,#,Plantation SDP Route Distances,EditDate,-1,-1;Editor "Editor" false true true 128 Text 0 0,First,#,Plantation SDP Route Distances,Editor,0,128'
)
print ("Existing SDP Route distances exported")&lt;/LI-CODE&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Exception: Failed to execute. Parameters are not valid.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;ERROR 000732: Input Table: Dataset &lt;A href="https://services3.arcgis.com/1GMgEwgl0qHnrBQf/arcgis/rest/services/Distances_Table/FeatureServer/0" target="_blank"&gt;https://services3.arcgis.com/1GMgEwgl0qHnrBQf/arcgis/rest/services/Distances_Table/FeatureServer/0&lt;/A&gt; does not exist or is not supported&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;Failed to execute (ExportTable).&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 01:20:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-feature-service-as-gp-tool-input/m-p/1303708#M68048</guid>
      <dc:creator>LindsayRaabe_FPCWA</dc:creator>
      <dc:date>2023-06-28T01:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using a feature service as GP tool input</title>
      <link>https://community.esri.com/t5/python-questions/using-a-feature-service-as-gp-tool-input/m-p/1303752#M68049</link>
      <description>&lt;P&gt;Hi Lindsay,&lt;/P&gt;&lt;P&gt;I didn't think that you could use a feature service as an input to the Export Table geoprocessing tool? In the documentation &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/conversion/export-table.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/tool-reference/conversion/export-table.htm&lt;/A&gt; it doesn't indicate that you can do that&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JoshuaSharpHeward_0-1687929057269.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/74334iCF349A363CE736E3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JoshuaSharpHeward_0-1687929057269.png" alt="JoshuaSharpHeward_0-1687929057269.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have managed to do something similar by having the web service in a map in an arcgis pro project before, and accessing the layer via ArcPy.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 05:14:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-feature-service-as-gp-tool-input/m-p/1303752#M68049</guid>
      <dc:creator>JoshuaSharp-Heward</dc:creator>
      <dc:date>2023-06-28T05:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using a feature service as GP tool input</title>
      <link>https://community.esri.com/t5/python-questions/using-a-feature-service-as-gp-tool-input/m-p/1303753#M68050</link>
      <description>&lt;P&gt;It's interesting. It was definitely working for me locally - just not when run server based. I've found an alternate solution now using the FeatureLayer module. Updated code below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Variables - update these lines
SDPRoutes = "https://services3.arcgis.com/1GMgEwgl0qHnrBQf/arcgis/rest/services/Distances_Table/FeatureServer/0" # Feature service containing routes to be updated

import arcpy, time, os
from arcgis.gis import GIS
from arcgis.features import FeatureLayer

# Overwrite Output
arcpy.env.overwriteOutput = True

arcpy.CheckOutExtension("Network")
print ("Network Analyst license checked-out")

# Create GIS object
print("Connecting to AGOL")
### Access the stored password with keyring and sign into the GIS      # https://community.esri.com/t5/arcgis-online-blog/connect-to-the-gis-in-python-scripts-without/ba-p/889867
import keyring
pw = keyring.get_password("ArcGISOnline", "MyUserName")
gis = GIS("https://fpcwa.maps.arcgis.com", "MyUserName", pw)
print("Connected to the GIS")

# Create temporary FGDB
sdproutesgdb = arcpy.CreateFileGDB_management(arcpy.env.scratchFolder, "sdproutes")
print ("Temp FGDB created")

arcpy.env.workspace = arcpy.env.scratchFolder + "\\sdproutes.gdb"
print ("Workspace set to temp FGDB")
   
fl = FeatureLayer(SDPRoutes)
fs = fl.query()
ExistingSDPRoutes = fs.save(arcpy.env.workspace, "ExistingSDPRoutes")
print ("Existing SDP Route distances exported")
    
ExistingSDPRoutes = arcpy.management.CalculateField(
    in_table = ExistingSDPRoutes,
    field = "Name",
    expression = '!Name!.split("_")[0]',
    expression_type = "PYTHON3",
    code_block = "",
    field_type = "TEXT",
    enforce_domains = "NO_ENFORCE_DOMAINS"
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 05:35:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-feature-service-as-gp-tool-input/m-p/1303753#M68050</guid>
      <dc:creator>LindsayRaabe_FPCWA</dc:creator>
      <dc:date>2023-06-28T05:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using a feature service as GP tool input</title>
      <link>https://community.esri.com/t5/python-questions/using-a-feature-service-as-gp-tool-input/m-p/1303756#M68051</link>
      <description>&lt;P&gt;Well I've learned two things today then! I didn't realise the "Save" method existed for feature sets in the ArcGIS API for Python, that seems very useful! Glad you've managed to find a solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 05:36:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-feature-service-as-gp-tool-input/m-p/1303756#M68051</guid>
      <dc:creator>JoshuaSharp-Heward</dc:creator>
      <dc:date>2023-06-28T05:36:13Z</dc:date>
    </item>
  </channel>
</rss>

