<?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 Search data in multiple input feature layers in specific database custom GP tool in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/search-data-in-multiple-input-feature-layers-in/m-p/1344584#M69111</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am creating an GP tool which has one of the params of type GPLayer and also it is multi-value. We can select multiple layers.&lt;/P&gt;&lt;P&gt;I have to loop through the &amp;nbsp;selected input layer params and run some business logic based on feature layers data. Right now I am using SearchCursor to do that. But I can have cases where there are 2 databases and user can add same feature layers from the 2 DBs in the active map. Now in GP tool we will have same features from 2 different DBs but SearchCursor will not work correctly since it works on feature name and both features will have the same name. How to search data in both features in their respective dbs?&lt;/P&gt;&lt;P&gt;Also how can we get the table name from these feature layers?&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/86309"&gt;@EarlMedina&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1371"&gt;@JoshuaBixby&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Nov 2023 18:35:22 GMT</pubDate>
    <dc:creator>CarlosK</dc:creator>
    <dc:date>2023-11-01T18:35:22Z</dc:date>
    <item>
      <title>Search data in multiple input feature layers in specific database custom GP tool</title>
      <link>https://community.esri.com/t5/python-questions/search-data-in-multiple-input-feature-layers-in/m-p/1344584#M69111</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am creating an GP tool which has one of the params of type GPLayer and also it is multi-value. We can select multiple layers.&lt;/P&gt;&lt;P&gt;I have to loop through the &amp;nbsp;selected input layer params and run some business logic based on feature layers data. Right now I am using SearchCursor to do that. But I can have cases where there are 2 databases and user can add same feature layers from the 2 DBs in the active map. Now in GP tool we will have same features from 2 different DBs but SearchCursor will not work correctly since it works on feature name and both features will have the same name. How to search data in both features in their respective dbs?&lt;/P&gt;&lt;P&gt;Also how can we get the table name from these feature layers?&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/86309"&gt;@EarlMedina&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1371"&gt;@JoshuaBixby&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 18:35:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-data-in-multiple-input-feature-layers-in/m-p/1344584#M69111</guid>
      <dc:creator>CarlosK</dc:creator>
      <dc:date>2023-11-01T18:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: Search data in multiple input feature layers in specific database custom GP tool</title>
      <link>https://community.esri.com/t5/python-questions/search-data-in-multiple-input-feature-layers-in/m-p/1344648#M69112</link>
      <description>&lt;P&gt;can someone help me here with this one?&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/458875"&gt;@AlfredBaldenweck&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/191789"&gt;@BlakeTerhune&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/15530"&gt;@RhettZufelt&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 19:49:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-data-in-multiple-input-feature-layers-in/m-p/1344648#M69112</guid>
      <dc:creator>CarlosK</dc:creator>
      <dc:date>2023-11-01T19:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: Search data in multiple input feature layers in specific database custom GP tool</title>
      <link>https://community.esri.com/t5/python-questions/search-data-in-multiple-input-feature-layers-in/m-p/1344698#M69114</link>
      <description>&lt;P&gt;Where you access the parameters in the execute portion, get it with the &lt;FONT face="courier new,courier"&gt;value&lt;/FONT&gt; property instead of &lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;valueAsText&lt;/FONT&gt;. From there, you can get the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/describe-object-properties.htm" target="_self"&gt;catalogPath from Describe&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;arcpy.Describe(the_layer_obj).catalogPath&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;Use the catalogPath when you create the cursor.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Apologies if this is oversimplified for your use case. I haven't worked with multi-value inputs.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 21:07:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-data-in-multiple-input-feature-layers-in/m-p/1344698#M69114</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2023-11-01T21:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Search data in multiple input feature layers in specific database custom GP tool</title>
      <link>https://community.esri.com/t5/python-questions/search-data-in-multiple-input-feature-layers-in/m-p/1345678#M69133</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

def getParameterInfo(self):
    
    # Ask User for Input Features
        features = arcpy.Parameter(
            displayName="Input Features",
            name="in_features",
            datatype="GPFeatureLayer",
            parameterType="Required",
            direction="Input",
            multiValue=True)
        
        params = [features]
        
        return params

def execute(self, parameters, messages):
    
    # Get the layers from the parameters
    layers = parameters[0].values
    # Using data access (returns a python dictionary of properties, easy to debug)
    sources = [arcpy.da.Describe(layer.valueAsText)['catalogPath'] for layer in layers]
    
    # Using the arcpy Describe object (returns a arcpy Describe object, harder to debug)
    # sources = [arcpy.Describe(source).catalogPath for source in sources]
    
    def business_logic_process(featureclass:str) -&amp;gt; None:
        """Process a feature class
           @featureclass: The feature class to process
        """
        # Implement business logic here
        pass
    
    # Iterate data sources
    processed = []
    for source in sources:
        if source in processed:
            arcpy.AddMessage(f"Skipping {source}, already processed")
            continue
        try:
            business_logic_process(source)
        except Exception as e:
            arcpy.AddError(f"Failed to process {source}, {e}")
            
    return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That should be a good starting point. I added some checks to make sure you don't accidentally process the same source twice (if someone duplicated a layer), and also added a try except block that will allow the rest of the features to be processed if one throws an error during your logic function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 17:53:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-data-in-multiple-input-feature-layers-in/m-p/1345678#M69133</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2023-11-03T17:53:34Z</dc:date>
    </item>
  </channel>
</rss>

