<?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: Filter script tool parameter to unique field values in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/filter-script-tool-parameter-to-unique-field/m-p/1254772#M8343</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/116479"&gt;@ZenMasterZeke&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where are you making the tool, ArcGIS Pro, ArcMap or alternative?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have achieved this in ArcGIS Pro Custom Tool using the following in the Validation tab of the Tool Properties.&lt;/P&gt;&lt;P&gt;Get the url for the feature layer (not the feature service). This ends in a number specifying the layer number, generally 0 (zero) if only one layer.&lt;/P&gt;&lt;P&gt;Use set comprehension to return a set of all unique (change the FIELD_NAME to match yours).&amp;nbsp; This is wrapped in a list function because the filter must be a list.&lt;/P&gt;&lt;P&gt;Initialize the parameter, [0] here indicates the filter is the first parameter. This workflow assumes that the first parameter is a string and that the Site field is also a string.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    def initializeParameters(self):
        # Customize parameter properties. 
        # This gets called when the tool is opened.
        url = "url to the LAYER in the Feature Service"
        site_list = list({site[0] for site in arcpy.da.SearchCursor(url, "FIELD_NAME")})
        self.params[0].filter.list = site_list
        return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Feb 2023 09:29:42 GMT</pubDate>
    <dc:creator>Clubdebambos</dc:creator>
    <dc:date>2023-02-03T09:29:42Z</dc:date>
    <item>
      <title>Filter script tool parameter to unique field values</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/filter-script-tool-parameter-to-unique-field/m-p/1254636#M8338</link>
      <description>&lt;P&gt;Howdy!&lt;/P&gt;&lt;P&gt;I'm writing a python tool to download data from a hosted feature layer in our Portal to a csv file. I've got it working when downloading all data, but I want to be able to filter the data based on the Site field. What I'd like to have is the Site parameter in the tool be a dropdown of the unique values in the Site field.&lt;/P&gt;&lt;P&gt;I can do this if I manually fill in a Value List for the parameter, but ideally it should read them from the layer. Even better, I could also use this to filter the gis.content.get call, but I don't see a filter option there. I can filter the results in a dataframe before exporting to csv if necessary, but still don't know how to populate the parameter list. Is this possible? Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 21:53:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/filter-script-tool-parameter-to-unique-field/m-p/1254636#M8338</guid>
      <dc:creator>ZenMasterZeke</dc:creator>
      <dc:date>2023-02-02T21:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Filter script tool parameter to unique field values</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/filter-script-tool-parameter-to-unique-field/m-p/1254772#M8343</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/116479"&gt;@ZenMasterZeke&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where are you making the tool, ArcGIS Pro, ArcMap or alternative?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have achieved this in ArcGIS Pro Custom Tool using the following in the Validation tab of the Tool Properties.&lt;/P&gt;&lt;P&gt;Get the url for the feature layer (not the feature service). This ends in a number specifying the layer number, generally 0 (zero) if only one layer.&lt;/P&gt;&lt;P&gt;Use set comprehension to return a set of all unique (change the FIELD_NAME to match yours).&amp;nbsp; This is wrapped in a list function because the filter must be a list.&lt;/P&gt;&lt;P&gt;Initialize the parameter, [0] here indicates the filter is the first parameter. This workflow assumes that the first parameter is a string and that the Site field is also a string.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    def initializeParameters(self):
        # Customize parameter properties. 
        # This gets called when the tool is opened.
        url = "url to the LAYER in the Feature Service"
        site_list = list({site[0] for site in arcpy.da.SearchCursor(url, "FIELD_NAME")})
        self.params[0].filter.list = site_list
        return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 09:29:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/filter-script-tool-parameter-to-unique-field/m-p/1254772#M8343</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2023-02-03T09:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: Filter script tool parameter to unique field values</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/filter-script-tool-parameter-to-unique-field/m-p/1254808#M8344</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;A href="https://community.esri.com/t5/user/viewprofilepage/user-id/417766" target="_self"&gt;&lt;SPAN class=""&gt;Clubdebambos&lt;/SPAN&gt;&lt;/A&gt;! I'm using ArcGIS Pro 2.9.5. I'll give this a shot.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 13:14:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/filter-script-tool-parameter-to-unique-field/m-p/1254808#M8344</guid>
      <dc:creator>ZenMasterZeke</dc:creator>
      <dc:date>2023-02-03T13:14:13Z</dc:date>
    </item>
  </channel>
</rss>

