<?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: Update Parameters in Toolbox after refreshing selection in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/update-parameters-in-toolbox-after-refreshing/m-p/1391993#M70020</link>
    <description>&lt;P&gt;I would vote for an idea to make that refresh button call updateParameters().&lt;/P&gt;</description>
    <pubDate>Wed, 06 Mar 2024 17:26:43 GMT</pubDate>
    <dc:creator>AlfredBaldenweck</dc:creator>
    <dc:date>2024-03-06T17:26:43Z</dc:date>
    <item>
      <title>Update Parameters in Toolbox after refreshing selection</title>
      <link>https://community.esri.com/t5/python-questions/update-parameters-in-toolbox-after-refreshing/m-p/1390514#M70005</link>
      <description>&lt;P&gt;I have a python toolbox with a 'GPFeatureLayer' parameter, and a 'GPString' parameter.&amp;nbsp; The string field is a dropdown populated with the unique values of an ID field in my feature layer.&amp;nbsp; If there is a selection on the feature layer, the dropdown value list is correctly populated using just that selection.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the user updates their selection, the list does not update.&amp;nbsp; Clicking the refresh arrows next to "&lt;FONT color="#3366FF"&gt;The input has a selection. Records to be processed: X&lt;/FONT&gt;" does&amp;nbsp;&lt;EM&gt;not&lt;/EM&gt; call updateParameters().&amp;nbsp; The user must select a&amp;nbsp;new feature layer and the reselect the old feature layer to force the update, or close the tool and reopen it. This is not the desired workflow.&lt;/P&gt;&lt;P&gt;Is there any way to force a parameter update when refreshing the selection? Can ESRI staff perhaps help me find the clearest language to make a new Idea post to ask for this functionality?&amp;nbsp; Something like&amp;nbsp;&lt;STRONG&gt;Geoprocessing Tool Selection Refresh should call&amp;nbsp;updateParameters() in python toolbox.&lt;/STRONG&gt;&amp;nbsp;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 16:56:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-parameters-in-toolbox-after-refreshing/m-p/1390514#M70005</guid>
      <dc:creator>BrennanSmith1</dc:creator>
      <dc:date>2024-03-04T16:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Update Parameters in Toolbox after refreshing selection</title>
      <link>https://community.esri.com/t5/python-questions/update-parameters-in-toolbox-after-refreshing/m-p/1391637#M70017</link>
      <description>&lt;P&gt;Hi, is it possible to share your script in the validation tool?&lt;/P&gt;&lt;P&gt;This is my dummy script&lt;/P&gt;&lt;P&gt;In the parameters, I have this configuration&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlexanderDanielPratama_0-1709699339872.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/96991i32A210411F51B071/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlexanderDanielPratama_0-1709699339872.png" alt="AlexanderDanielPratama_0-1709699339872.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then in the validation, I insert this script. The key is in the conditional of params[0] and has a value. Then, by using arcpy.da.SearchCursor to iterate a column that we desired.&amp;nbsp; Don't forget to put the iteration value to an empty list that has been defined before.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlexanderDanielPratama_1-1709699382286.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/96992i8936DACED52515CB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlexanderDanielPratama_1-1709699382286.png" alt="AlexanderDanielPratama_1-1709699382286.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Last is running the script. The filtered_value will show the value from the parameter feature layer that has been selected in my case.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlexanderDanielPratama_3-1709699645920.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/96994iD7A6B27BECCE9005/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlexanderDanielPratama_3-1709699645920.png" alt="AlexanderDanielPratama_3-1709699645920.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Hope it helps you,&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 04:37:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-parameters-in-toolbox-after-refreshing/m-p/1391637#M70017</guid>
      <dc:creator>AlexanderDanielPratama</dc:creator>
      <dc:date>2024-03-06T04:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Update Parameters in Toolbox after refreshing selection</title>
      <link>https://community.esri.com/t5/python-questions/update-parameters-in-toolbox-after-refreshing/m-p/1391786#M70018</link>
      <description>&lt;P&gt;My dropdown list is populating correctly. The issue is that if the selection changes while the tool is open, clicking the refresh arrows does not call&amp;nbsp;updateParameters() and does not update the dropdown.&amp;nbsp; Below is a screenshot, and an example .pyt script.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BrennanSmith1_0-1709731863801.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/97046i2DF3A5CA5B2D2007/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrennanSmith1_0-1709731863801.png" alt="BrennanSmith1_0-1709731863801.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

class Toolbox(object):
    def __init__(self):
        self.label = "Toolbox"
        self.alias = "toolbox"
        self.tools = [Tool]

class Tool(object):
    def __init__(self):
        self.label = "Tool"
        self.description = ""
        self.canRunInBackground = False

    def getParameterInfo(self):
        # Feauture Layer
        fc = arcpy.Parameter(
            displayName="Define Feature Layer",
            name="fc",
            datatype="GPFeatureLayer",
            parameterType="Required",
            direction="Input")
        
        # Drop down of OIDs from feature layer
        oids = arcpy.Parameter(
            displayName="Select OID",
            name="oids",
            datatype="GPString",
            parameterType="Required",
            direction="Input")    
            
        params = [fc,oids]
        return params

    def updateParameters(self, parameters):

        #if feature layer is defined
        if parameters[0].altered and not parameters[0].hasBeenValidated:
            #get list of OIDs
            oidfield = arcpy.Describe(parameters[0].value).OIDFieldName
            oidlist = [row[0] for row in arcpy.da.SearchCursor(parameters[0].value, oidfield)]
            #and populate the dropdown
            parameters[1].filter.list = oidlist
            parameters[1].value = oidlist[0]
        return

    def execute(self, parameters, messages):
        
        return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 13:31:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-parameters-in-toolbox-after-refreshing/m-p/1391786#M70018</guid>
      <dc:creator>BrennanSmith1</dc:creator>
      <dc:date>2024-03-06T13:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Update Parameters in Toolbox after refreshing selection</title>
      <link>https://community.esri.com/t5/python-questions/update-parameters-in-toolbox-after-refreshing/m-p/1391981#M70019</link>
      <description>&lt;P&gt;I was able to craft a workaround.&amp;nbsp; I still think that clicking the refresh icon should call updateParameters(), but for anyone else encountering this issue in the meantime&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Add a new GPBoolean parameter, named something like "Click here to force update selection"&lt;/LI&gt;&lt;LI&gt;Compare the ID value to its own filter list, and update if necessary&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="python"&gt;    def updateParameters(self, parameters):

        #get list of OIDs
        oidfield = arcpy.Describe(parameters[0].value).OIDFieldName
        oidlist = [row[0] for row in arcpy.da.SearchCursor(parameters[0].value, oidfield)]
        
        #whenever feature layer is defined, populate list of IDs
        if parameters[0].altered and not parameters[0].hasBeenValidated:
            #and populate the dropdown
            parameters[1].filter.list = oidlist
            parameters[1].value = oidlist[0]
            
        #make sure that list of IDs is always up to date, and replace any bad values
        if parameters[1].value not in oidlist:
            parameters[1].filter.list = oidlist
        if parameters[1].value not in parameters[1].filter.list:
            parameters[1].value = parameters[1].filter.list[0]
            
        return
        &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 17:12:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-parameters-in-toolbox-after-refreshing/m-p/1391981#M70019</guid>
      <dc:creator>BrennanSmith1</dc:creator>
      <dc:date>2024-03-06T17:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: Update Parameters in Toolbox after refreshing selection</title>
      <link>https://community.esri.com/t5/python-questions/update-parameters-in-toolbox-after-refreshing/m-p/1391993#M70020</link>
      <description>&lt;P&gt;I would vote for an idea to make that refresh button call updateParameters().&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 17:26:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-parameters-in-toolbox-after-refreshing/m-p/1391993#M70020</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2024-03-06T17:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: Update Parameters in Toolbox after refreshing selection</title>
      <link>https://community.esri.com/t5/python-questions/update-parameters-in-toolbox-after-refreshing/m-p/1392005#M70021</link>
      <description>&lt;P&gt;I created the Idea here, thank you.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-ideas/selection-refresh-should-call-updateparameters/idi-p/1392004" target="_blank"&gt;https://community.esri.com/t5/arcgis-pro-ideas/selection-refresh-should-call-updateparameters/idi-p/1392004&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 17:43:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-parameters-in-toolbox-after-refreshing/m-p/1392005#M70021</guid>
      <dc:creator>BrennanSmith1</dc:creator>
      <dc:date>2024-03-06T17:43:48Z</dc:date>
    </item>
  </channel>
</rss>

