<?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: Toolbox numerical field clears when you select a filtered parameter in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/toolbox-numerical-field-clears-when-you-select-a/m-p/1328030#M68618</link>
    <description>&lt;P&gt;Hard to say without your parameter declarations and update conditions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My favorite workaround is to build a dictionary of parameters and store it in a class variable then call an update function whenever the update function runs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;self.params = dict(zip([(p.name, p) for p in parameters]))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;maybe using that at the top of your updateParameters function will help you debug in your execute. If the value in the object parameters (self.params) differs from the parameter value passed to the execute function, then it means something in your update function is causing issues&lt;/P&gt;</description>
    <pubDate>Tue, 12 Sep 2023 22:31:39 GMT</pubDate>
    <dc:creator>HaydenWelch</dc:creator>
    <dc:date>2023-09-12T22:31:39Z</dc:date>
    <item>
      <title>Toolbox numerical field clears when you select a filtered parameter</title>
      <link>https://community.esri.com/t5/python-questions/toolbox-numerical-field-clears-when-you-select-a/m-p/1327810#M68593</link>
      <description>&lt;P&gt;If I edit a field with type GPLong, and then edit a field with a filtered drop-down menu, the numerical field clears/reverts to the previous value. If I edit the first field, press tab or click the background, and then edit the drop-down field, the edits stay.&lt;/P&gt;&lt;P&gt;I observed this with a custom tool and a default Pro tool. It does not appear to happen if you go directly from a numerical to a text field, or a text field to a filtered field.&lt;/P&gt;&lt;P&gt;Is this something that can be "fixed", or is it an unavoidable part of how parameter inputs get validated?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm afraid I might not be explaining clearly enough so I will write it like a table too:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%"&gt;&lt;P&gt;- type in numerical field&lt;BR /&gt;- click&amp;nbsp;&lt;U&gt;directly&lt;/U&gt; on a filtered field&lt;BR /&gt;- change filtered field&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;✗&amp;nbsp;&lt;/SPAN&gt;numerical field&amp;nbsp;&lt;U&gt;does not&lt;/U&gt; keep update&lt;/P&gt;&lt;/TD&gt;&lt;TD width="25%"&gt;&lt;P&gt;- type in numerical field&lt;BR /&gt;- press tab or click outside any field&lt;BR /&gt;- change filtered field&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;✓ numerical field&amp;nbsp;&lt;U&gt;does&lt;/U&gt; keep update&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD width="25%"&gt;&lt;P&gt;- type in numerical field&lt;BR /&gt;- click&amp;nbsp;&lt;U&gt;directly&lt;/U&gt; on a&amp;nbsp;&lt;EM&gt;text&lt;/EM&gt; field&lt;BR /&gt;- change (non-filtered) text field&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;✓ numerical field&amp;nbsp;&lt;U&gt;does&lt;/U&gt; keep update&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD width="25%"&gt;&amp;nbsp;- type in &lt;I&gt;text&lt;/I&gt;&amp;nbsp;field&lt;P&gt;- click&amp;nbsp;&lt;U&gt;directly&lt;/U&gt; on a&amp;nbsp;&lt;EM&gt;filtered&lt;/EM&gt; field&lt;BR /&gt;- change filtered field&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;✓ text field&amp;nbsp;&lt;U&gt;does&lt;/U&gt; keep update&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks - Sam&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 16:16:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/toolbox-numerical-field-clears-when-you-select-a/m-p/1327810#M68593</guid>
      <dc:creator>samuel_e</dc:creator>
      <dc:date>2023-09-12T16:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: Toolbox numerical field clears when you select a filtered parameter</title>
      <link>https://community.esri.com/t5/python-questions/toolbox-numerical-field-clears-when-you-select-a/m-p/1328030#M68618</link>
      <description>&lt;P&gt;Hard to say without your parameter declarations and update conditions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My favorite workaround is to build a dictionary of parameters and store it in a class variable then call an update function whenever the update function runs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;self.params = dict(zip([(p.name, p) for p in parameters]))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;maybe using that at the top of your updateParameters function will help you debug in your execute. If the value in the object parameters (self.params) differs from the parameter value passed to the execute function, then it means something in your update function is causing issues&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 22:31:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/toolbox-numerical-field-clears-when-you-select-a/m-p/1328030#M68618</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2023-09-12T22:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: Toolbox numerical field clears when you select a filtered parameter</title>
      <link>https://community.esri.com/t5/python-questions/toolbox-numerical-field-clears-when-you-select-a/m-p/1328351#M68631</link>
      <description>&lt;P&gt;Hi Hayden, thanks for your suggestion. I might not have been clear enough but I was encountering this while still editing the tool not after running. So I believe it is all within updateParameters(), if it is in our code at all. I'll look into the changes you suggested.&lt;/P&gt;&lt;P&gt;However, we have now found that the behavior seems to only occur in version 3.1.x. Therefore we are treating it as a likely ArcGIS Pro bug rather than an error in our code. (I'll update this post for any future visitors if I hear back about the bug report.)&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 15:59:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/toolbox-numerical-field-clears-when-you-select-a/m-p/1328351#M68631</guid>
      <dc:creator>samuel_e</dc:creator>
      <dc:date>2023-09-13T15:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: Toolbox numerical field clears when you select a filtered parameter</title>
      <link>https://community.esri.com/t5/python-questions/toolbox-numerical-field-clears-when-you-select-a/m-p/1328367#M68632</link>
      <description>&lt;P&gt;Just ran a test and wrote the parameter values out to a warning message as they changed. You're definitely correct that it seems Esri introduced some sort of focus bug on the element for number inputs.&lt;/P&gt;&lt;P&gt;The value isn't written into the parameter until focus is lost, but with the number field, it seems that changing focus to any other parameter input box clears the focus without then writing the value to the parameter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For now, a good workaroud might be to have numeric parameters defined as 'GPString' with this updateParameters() check:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    def updateParameters(self, parameters: list) -&amp;gt; None:
        self.params = archelp.get_params(parameters) # Replace this with index
        if self.params["number"].altered:
            if not self.params["number"].valueAsText.isnumeric():
                self.params["number"].setErrorMessage("Number must be numeric")
                self.params["number"].value = None
        return&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 13 Sep 2023 16:27:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/toolbox-numerical-field-clears-when-you-select-a/m-p/1328367#M68632</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2023-09-13T16:27:58Z</dc:date>
    </item>
  </channel>
</rss>

