<?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 script tool parameters to update a multiple choice list of values to select from based on a fields attributes? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-script-tool-parameters-to-update-a-multiple/m-p/1096380#M62272</link>
    <description>&lt;P&gt;I figured out the issue. I wasn't sure why I didn't notice it before but the tool is working with the exception of the indexing error that I need to troubleshoot.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;class ToolValidator:
    # Class to add custom behavior and properties to the tool and tool parameters.

    def __init__(self):
        # set self.params for use in other function
        self.params = arcpy.GetParameterInfo()

    def initializeParameters(self):
        # Customize parameter properties. 
        # This gets called when the tool is opened.
        return

    def updateParameters(self):
        # Modify parameter values and properties.
        # This gets called each time a parameter is modified, before 
        # standard validation.
        featureclass = self.params[2].value
        fieldname = self.params[3].value
        SubdivisionLayers = self.params[4].filter
        if featureclass:
            fcfields = [field.name for field in arcpy.ListFields(featureclass) if field.name == fieldname]
            attributevalues = [row[0] for row in arcpy.da.SearchCursor(featureclass, fcfields)]
            UniqueAttributes = set(attributevalues)
            SubdivisionLayers.list = [str(value) for value in UniqueAttributes]
            
        return

    def updateMessages(self):
        # Customize messages for the parameters.
        # This gets called after standard validation.
        return

    # def isLicensed(self):
    #     # set tool isLicensed.
    #     return True&lt;/LI-CODE&gt;&lt;P&gt;The other issue is that it is passing the values with a ';' in between. I think I know a workaround but I will keep trying or create another post for any assistance.&lt;/P&gt;</description>
    <pubDate>Wed, 08 Sep 2021 14:21:25 GMT</pubDate>
    <dc:creator>RPGIS</dc:creator>
    <dc:date>2021-09-08T14:21:25Z</dc:date>
    <item>
      <title>Using script tool parameters to update a multiple choice list of values to select from based on a fields attributes?</title>
      <link>https://community.esri.com/t5/python-questions/using-script-tool-parameters-to-update-a-multiple/m-p/1096098#M62261</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I was wondering if there was a way to set up the script tool parameters to update a multiple choice selection list based on a fields attribute values. I think I set it up correctly ( by all means correct me if it is wrong ) but it doesn't seem to be working accordingly. I might be missing something, but since I generally never mess with this, it is a bit foreign to me. Any help on this would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;class ToolValidator:
    # Class to add custom behavior and properties to the tool and tool parameters.

    def __init__(self):
        # set self.params for use in other function
        self.params = arcpy.GetParameterInfo()

    def initializeParameters(self):
        # Customize parameter properties. 
        # This gets called when the tool is opened.
        return

    def updateParameters(self):
        # Modify parameter values and properties.
        # This gets called each time a parameter is modified, before 
        # standard validation.

        if params[3].value:
            fcfields = [field.name for field in arcpy.ListFields(params[3].value) if field.name == params[4].valueAsText]
            attributevalues = [row for row in arcpy.da.SearchCursor(featureclass, fcfields)]
            self.params[5].filter.list = set(attributevalues)
            
        return

    def updateMessages(self):
        # Customize messages for the parameters.
        # This gets called after standard validation.
        return

    # def isLicensed(self):
    #     # set tool isLicensed.
    #     return True&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 20:03:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-script-tool-parameters-to-update-a-multiple/m-p/1096098#M62261</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2021-09-07T20:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using script tool parameters to update a multiple choice list of values to select from based on a fields attributes?</title>
      <link>https://community.esri.com/t5/python-questions/using-script-tool-parameters-to-update-a-multiple/m-p/1096103#M62262</link>
      <description>&lt;P&gt;Try indexing your row in your list comp:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;attributevalues = [row[0] for row in arcpy.da.SearchCursor(featureclass, fcfields)]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 20:12:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-script-tool-parameters-to-update-a-multiple/m-p/1096103#M62262</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-09-07T20:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using script tool parameters to update a multiple choice list of values to select from based on a fields attributes?</title>
      <link>https://community.esri.com/t5/python-questions/using-script-tool-parameters-to-update-a-multiple/m-p/1096131#M62263</link>
      <description>&lt;P&gt;Looks like you might need to change params[] to self.params[] in a couple of places.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 20:52:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-script-tool-parameters-to-update-a-multiple/m-p/1096131#M62263</guid>
      <dc:creator>nzjs</dc:creator>
      <dc:date>2021-09-07T20:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using script tool parameters to update a multiple choice list of values to select from based on a fields attributes?</title>
      <link>https://community.esri.com/t5/python-questions/using-script-tool-parameters-to-update-a-multiple/m-p/1096330#M62271</link>
      <description>&lt;P&gt;So I tried both of your suggestions, but I am still not getting the multiple selection that I am looking for. Here is the updated script but I can't seem to figure out what I am missing.&lt;/P&gt;&lt;P&gt;Do I need to initialize a parameter first before using the update parameter? If this is all correct then any ideas on how to accomplish this. I have never tinkered with the tool validations before so this is all new territory for me.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;class ToolValidator:
    # Class to add custom behavior and properties to the tool and tool parameters.

    def __init__(self):
        # set self.params for use in other function
        self.params = arcpy.GetParameterInfo()

    def initializeParameters(self):
        # Customize parameter properties. 
        # This gets called when the tool is opened.
        return

    def updateParameters(self):
        # Modify parameter values and properties.
        # This gets called each time a parameter is modified, before 
        # standard validation.

        if self.params[3].value:
            featureclass = self.params[3].value
            fcfields = [field.name for field in arcpy.ListFields(featureclass) if field.name == self.params[4].valueAsText]
            attributevalues = [row[0] for row in arcpy.da.SearchCursor(featureclass, fcfields)]
            self.params[5].filter.list = set(attributevalues)
            
        return

    def updateMessages(self):
        # Customize messages for the parameters.
        # This gets called after standard validation.
        return

    # def isLicensed(self):
    #     # set tool isLicensed.
    #     return True&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 08 Sep 2021 12:35:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-script-tool-parameters-to-update-a-multiple/m-p/1096330#M62271</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2021-09-08T12:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using script tool parameters to update a multiple choice list of values to select from based on a fields attributes?</title>
      <link>https://community.esri.com/t5/python-questions/using-script-tool-parameters-to-update-a-multiple/m-p/1096380#M62272</link>
      <description>&lt;P&gt;I figured out the issue. I wasn't sure why I didn't notice it before but the tool is working with the exception of the indexing error that I need to troubleshoot.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;class ToolValidator:
    # Class to add custom behavior and properties to the tool and tool parameters.

    def __init__(self):
        # set self.params for use in other function
        self.params = arcpy.GetParameterInfo()

    def initializeParameters(self):
        # Customize parameter properties. 
        # This gets called when the tool is opened.
        return

    def updateParameters(self):
        # Modify parameter values and properties.
        # This gets called each time a parameter is modified, before 
        # standard validation.
        featureclass = self.params[2].value
        fieldname = self.params[3].value
        SubdivisionLayers = self.params[4].filter
        if featureclass:
            fcfields = [field.name for field in arcpy.ListFields(featureclass) if field.name == fieldname]
            attributevalues = [row[0] for row in arcpy.da.SearchCursor(featureclass, fcfields)]
            UniqueAttributes = set(attributevalues)
            SubdivisionLayers.list = [str(value) for value in UniqueAttributes]
            
        return

    def updateMessages(self):
        # Customize messages for the parameters.
        # This gets called after standard validation.
        return

    # def isLicensed(self):
    #     # set tool isLicensed.
    #     return True&lt;/LI-CODE&gt;&lt;P&gt;The other issue is that it is passing the values with a ';' in between. I think I know a workaround but I will keep trying or create another post for any assistance.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 14:21:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-script-tool-parameters-to-update-a-multiple/m-p/1096380#M62272</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2021-09-08T14:21:25Z</dc:date>
    </item>
  </channel>
</rss>

