<?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: Script tool with drop down list of multi values using ToolValidator in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1107809#M62651</link>
    <description>&lt;P&gt;the blog was from 2011 and for ArcMap and the code link was no good, so I can only guess.&lt;/P&gt;&lt;P&gt;The parameter would have to be multivalue&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/working-with-multivalue-inputs.htm" target="_blank"&gt;Working with multivalue inputs—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;so that would have to be set up in your script as either a list or a semicolon separated string&lt;/P&gt;</description>
    <pubDate>Fri, 15 Oct 2021 07:05:21 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2021-10-15T07:05:21Z</dc:date>
    <item>
      <title>Script tool with drop down list of multi values using ToolValidator</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1107771#M62648</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I need an idea on how to enable a drop down list in a script tool so that I can select multiple attribute values from a selected field.&lt;/P&gt;&lt;P&gt;Based on a code from ArcGIS blog, "&lt;A href="https://www.esri.com/arcgis-blog/products/arcgis-desktop/analytics/generating-a-choice-list-from-a-field/?rmedium=blogs_esri_com&amp;amp;rsource=/esri/arcgis/2011/08/25/generating-a-choice-list-from-a-field/" target="_self"&gt;Generating a choice list from a field&lt;/A&gt;", I managed to create a script tool with ToolValidator function to make a a drop down list.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="A0328_0-1634261251130.png"&gt;&lt;img src="https://community.esri.com/skins/images/A8FE17D2A003BAE3BAC79F0CC9E511AE/responsive_peak/images/image_not_found.png" alt="A0328_0-1634261251130.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But I cannot select multiple values with this code only. I can check the box of "Multiple values" in Parameters section. This makes multiple values windows but even if I select multiple values, the values won't be included as inputs. So, I feel the script in validation section needs to be modified but I am struggling with that.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 01:43:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1107771#M62648</guid>
      <dc:creator>Aнастасия88</dc:creator>
      <dc:date>2021-10-15T01:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool with drop down list of multi values using ToolValidator</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1107783#M62649</link>
      <description>&lt;P&gt;There are discussions here&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-questions/create-script-tool-with-sortable-field-multi-value/td-p/487318" target="_blank"&gt;Solved: Create Script Tool with Sortable Field Multi-Value... - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and here&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-questions/using-script-tool-parameters-to-update-a-multiple/td-p/1096098" target="_blank"&gt;Solved: Using script tool parameters to update a multiple ... - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;My preference is to use "Custom tools" and do minor validation within the validation code contained in the tool.&amp;nbsp; You get a better link (without coding) and a visual representation of the dialog parameters that isn't available in "python tools" ... kind of a misnomer since both of them are "python" at their root in the new toolbox structure introduces in Pro 2.8 and evident in beta 2.9.&lt;/P&gt;&lt;P&gt;See the help topics within this general area&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/comparing-custom-and-python-toolboxes.htm" target="_blank"&gt;Comparing custom and Python toolboxes—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 02:24:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1107783#M62649</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-10-15T02:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool with drop down list of multi values using ToolValidator</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1107794#M62650</link>
      <description>&lt;P&gt;Hi Dan, thanks for your advice.&lt;/P&gt;&lt;P&gt;I had already created the script tool in the custom toolbox and applied the validation code that I found it from the blog. But this way does not give me multiple values selection from the selected field unfortunately.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 04:09:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1107794#M62650</guid>
      <dc:creator>Aнастасия88</dc:creator>
      <dc:date>2021-10-15T04:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool with drop down list of multi values using ToolValidator</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1107809#M62651</link>
      <description>&lt;P&gt;the blog was from 2011 and for ArcMap and the code link was no good, so I can only guess.&lt;/P&gt;&lt;P&gt;The parameter would have to be multivalue&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/working-with-multivalue-inputs.htm" target="_blank"&gt;Working with multivalue inputs—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;so that would have to be set up in your script as either a list or a semicolon separated string&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 07:05:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1107809#M62651</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-10-15T07:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool with drop down list of multi values using ToolValidator</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1108274#M62665</link>
      <description>&lt;P&gt;Thanks for your help again.&lt;/P&gt;&lt;P&gt;I tick a box for Multiple Values in parameter. The data type is String. I think prepared a script to take the input as multiple values but it still does not work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My script for the multivalue input is below:&lt;/P&gt;&lt;P&gt;BName = arcpy.GetParameterAsText(2)&lt;BR /&gt;BName_list = BName.split(";")&lt;/P&gt;</description>
      <pubDate>Sun, 17 Oct 2021 23:14:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1108274#M62665</guid>
      <dc:creator>Aнастасия88</dc:creator>
      <dc:date>2021-10-17T23:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool with drop down list of multi values using ToolValidator</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1108276#M62666</link>
      <description>&lt;P&gt;Add an&lt;/P&gt;&lt;P&gt;arcpy.AddMessage(BName_list)&lt;/P&gt;&lt;P&gt;to see what it returns.&amp;nbsp; It should return a list of strings if it is semicolon delimited&lt;/P&gt;</description>
      <pubDate>Sun, 17 Oct 2021 23:28:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1108276#M62666</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-10-17T23:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool with drop down list of multi values using ToolValidator</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1108660#M62673</link>
      <description>&lt;P&gt;My script is:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;InputFeatureClass = arcpy.GetParameterAsText(0)
InputField = arcpy.GetParameterAsText(1)
InputValue = arcpy.GetParameterAsText(2)
InputValues = InputValue.replace("'","")
InputValue_list = InputValues.split(";")
arcpy.AddMessage("Input Values: {0}".format(InputValue_list))&lt;/LI-CODE&gt;&lt;P&gt;My parameters - data type is string and ticked Multiple Values:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="A0328_0-1634601270611.png"&gt;&lt;img src="https://community.esri.com/skins/images/A8FE17D2A003BAE3BAC79F0CC9E511AE/responsive_peak/images/image_not_found.png" alt="A0328_0-1634601270611.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Interface of the script tool allows me to select multiple values:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="A0328_1-1634601346380.png"&gt;&lt;img src="https://community.esri.com/skins/images/A8FE17D2A003BAE3BAC79F0CC9E511AE/responsive_peak/images/image_not_found.png" alt="A0328_1-1634601346380.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But even if I added the checked values, input ends up like this - it won't be multiple value for some reason.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="A0328_2-1634601455589.png"&gt;&lt;img src="https://community.esri.com/skins/images/A8FE17D2A003BAE3BAC79F0CC9E511AE/responsive_peak/images/image_not_found.png" alt="A0328_2-1634601455589.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 23:58:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1108660#M62673</guid>
      <dc:creator>Aнастасия88</dc:creator>
      <dc:date>2021-10-18T23:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool with drop down list of multi values using ToolValidator</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1108680#M62674</link>
      <description>&lt;P&gt;As I indicated earlier, I prefer custom toolboxes.&lt;/P&gt;&lt;P&gt;Here is on of my tools that accepts multiple values... to get a complete lists of possible selections, I just click on the little arrow beside the input parameter name (class fields in the case) and you end up with a list of checkboxes so you don't have to select one at a time.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="multivalue_parameter.png" style="width: 234px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/25485i945475448734F53F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="multivalue_parameter.png" alt="multivalue_parameter.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;try clicking on your arrow beside "Value"&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 03:09:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1108680#M62674</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-10-19T03:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool with drop down list of multi values using ToolValidator</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1108689#M62675</link>
      <description>&lt;P&gt;I think I created a script tool in same steps that are described here - "&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/adding-a-script-tool.htm" target="_self"&gt;Creating a script tools in a custom tool box&lt;/A&gt;".&lt;/P&gt;&lt;P&gt;Created like this below&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="A0328_0-1634613742120.png"&gt;&lt;img src="https://community.esri.com/skins/images/A8FE17D2A003BAE3BAC79F0CC9E511AE/responsive_peak/images/image_not_found.png" alt="A0328_0-1634613742120.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Do you mean this is not a "custom toolbox" that you mentioned?&lt;/P&gt;&lt;P&gt;As you can see the second picture above, I did open the drop -down list of values and checked multiple values and clicked "Add". However, it ends up with like the third picture, which is only one value is selected and I cannot add and change it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know what I am missing...&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 03:29:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1108689#M62675</guid>
      <dc:creator>Aнастасия88</dc:creator>
      <dc:date>2021-10-19T03:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool with drop down list of multi values using ToolValidator</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1108741#M62677</link>
      <description>&lt;P&gt;The multivalue selection returns a ";" delimited list and this is how I split it in the code&lt;/P&gt;&lt;P&gt;cls_flds = cls_flds.split(";")&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="multivalue_parameter01.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/25503iA6776CAEDC9C0717/image-size/medium?v=v2&amp;amp;px=400" role="button" title="multivalue_parameter01.png" alt="multivalue_parameter01.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;There is no extra validation code, just what you see.&amp;nbsp; in my case "Field" was the case with multiple values desired&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 08:51:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1108741#M62677</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-10-19T08:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool with drop down list of multi values using ToolValidator</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1109026#M62695</link>
      <description>&lt;P&gt;Thanks again for your help.&lt;/P&gt;&lt;P&gt;It looks like same as yours except my one is "Field value" and yours is "Field".&lt;/P&gt;&lt;P&gt;My validation code is like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
class ToolValidator(object):
  """Class for validating a tool's parameter values and controlling
  the behavior of the tool's dialog."""

  def __init__(self):
    """Setup arcpy and the list of tool parameters."""
    self.params = arcpy.GetParameterInfo()
    self.fcfield = (None, None)

  def initializeParameters(self):
    """Refine the properties of a tool's parameters.  This method is
    called when the tool is opened."""
    return

  def updateParameters(self):
    """Modify the values and properties of parameters before internal
    validation is performed.  This method is called whenever a parmater
    has been changed."""
    if self.params[0].value and self.params[1].value:
      fc, col = str(self.params[0].value), str(self.params[1].value)
      if self.fcfield != (fc, col):
        self.fcfield = (fc, col)
        self.params[2].filter.list = [str(val) for val in sorted(set(row.getValue(col) for row in arcpy.SearchCursor(fc, fields=col)))]
        if self.params[2].value not in self.params[2].filter.list:
            self.params[2].value = self.params[2].filter.list[0]

  def updateMessages(self):
    """Modify the messages created by internal validation for each tool
    parameter.  This method is called after internal validation."""
    return&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 19 Oct 2021 22:04:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1109026#M62695</guid>
      <dc:creator>Aнастасия88</dc:creator>
      <dc:date>2021-10-19T22:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool with drop down list of multi values using ToolValidator</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1109039#M62696</link>
      <description>&lt;P&gt;I am not sure the purpose of the last 2 lines (25, 26.&amp;nbsp; If you are providing the list of values to the tool from the field would that be in the initialize script?&lt;/P&gt;&lt;P&gt;Also if you are using a search cursor getting one value at a time,&amp;nbsp; there is no need to take a set of the returned value and sort it each time.&amp;nbsp; Get all the values, take its set, convert it to a list, then sort it&lt;/P&gt;&lt;LI-CODE lang="python"&gt;d = [2, 5, 5, 2, 6, 1, 3, 5, 4]  # emulate a searchcursor
# use a set comprehension
out = sorted(list({str(val) for val in d}))
out
['1', '2', '3', '4', '5', '6']&lt;/LI-CODE&gt;&lt;P&gt;Beyond that, I can't pinpoint anything else&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 22:48:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1109039#M62696</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-10-19T22:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool with drop down list of multi values using ToolValidator</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1109049#M62697</link>
      <description>&lt;P&gt;Thanks Dan, it works!&lt;/P&gt;&lt;P&gt;It seems like there is no need to put the last two lines as you mentioned.&lt;/P&gt;&lt;P&gt;Also, thanks for another advice for the better quality of the script.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 23:11:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1109049#M62697</guid>
      <dc:creator>Aнастасия88</dc:creator>
      <dc:date>2021-10-19T23:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool with drop down list of multi values using ToolValidator</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1109075#M62699</link>
      <description>&lt;P&gt;Glad it worked out&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 02:02:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-with-drop-down-list-of-multi-values/m-p/1109075#M62699</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-10-20T02:02:44Z</dc:date>
    </item>
  </channel>
</rss>

