<?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: ToolValidator 'setErrorMessage()' not activating. in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/toolvalidator-seterrormessage-not-activating/m-p/1566216#M91019</link>
    <description>&lt;P&gt;Thank you. Some examples did (seem to?) set error messages in other methods, but only the updateMessages method worked for me. Also,&amp;nbsp;&lt;EM&gt;combining&lt;/EM&gt; with updateParameters was necessary. The validator class is a little more complicated than I thought, and error messaging - with dynamic responsiveness - will take a little time to figure out. Thank you for your help.&lt;/P&gt;</description>
    <pubDate>Mon, 09 Dec 2024 14:45:49 GMT</pubDate>
    <dc:creator>RandyMcGregor_BMcD</dc:creator>
    <dc:date>2024-12-09T14:45:49Z</dc:date>
    <item>
      <title>ToolValidator 'setErrorMessage()' not activating.</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/toolvalidator-seterrormessage-not-activating/m-p/1565994#M90990</link>
      <description>&lt;P&gt;I have a tool that runs on layouts and I want to insert an error message if the activeview is not a layout. &lt;EM&gt;self.params[0].value = '&amp;gt;&amp;gt;&amp;gt; MUST BE IN LAYOUT VIEW&amp;lt;&amp;lt;&amp;lt;'&lt;/EM&gt; but &lt;EM&gt;self.params[0].setErrorMessage("Must be in layout view.")&lt;/EM&gt;&amp;nbsp;(which I would prefer to use because I think it would be a cleaner error-handling method) is completely, totally ignored and I just can't figure out why. The code is running after the "else:" (the active view is not a layout).&lt;/P&gt;&lt;P&gt;Is there some obvious, easy-to-spot mistake I'm making here? I would appreciate it anyone could see what's because I don't.&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Randy McGregor&lt;/P&gt;&lt;LI-CODE lang="c"&gt;def initializeParameters(self):
        # Customize parameter properties. This method gets called when the
        # tool is opened.
        aprx = arcpy.mp.ArcGISProject("CURRENT")
        av = aprx.activeView
        #if av.type =="LAYOUT":
        if isinstance(av,arcpy._mp.Layout):
            am = aprx.activeMap
            mf_filter = []
            mf_list = av.listElements("MAPFRAME_ELEMENT")
            # Load non-active map frames to filter list.
            for mf in mf_list:
                if mf.map.name != am.name:
                    mf_filter.append(mf.name)
            # Load the active map frame into the front position of the filter list,
            # so that it is the default map frame when the tool is opened.        
            for mf in mf_list:
                if mf.map.name == am.name:
                    mf_filter.insert(0,mf.name)
                    
            self.params[0].filter.list = mf_filter
            self.params[0].value = mf_filter[0]
        else:
            self.params[0].setErrorMessage("Must be in layout view.")
            ##self.params[0].filter.list=[]
            ##self.params[0].value = "&amp;gt;&amp;gt;&amp;gt;MUST BE IN LAYOUT VIEW TO USE THIS TOOL&amp;lt;&amp;lt;&amp;lt;"
        return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2024 22:10:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/toolvalidator-seterrormessage-not-activating/m-p/1565994#M90990</guid>
      <dc:creator>RandyMcGregor_BMcD</dc:creator>
      <dc:date>2024-12-07T22:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: ToolValidator 'setErrorMessage()' not activating.</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/toolvalidator-seterrormessage-not-activating/m-p/1566009#M90992</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/classes/parameter.htm" target="_blank"&gt;Parameter—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Example 3 uses an updateMessages method in conjunction with clearing the messages prior to adding the custome setErrorMessage.&amp;nbsp; If you want to use it in your existing, perhaps try clearing the message prior to setting it or try the updateMessages approach&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2024 23:42:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/toolvalidator-seterrormessage-not-activating/m-p/1566009#M90992</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2024-12-07T23:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: ToolValidator 'setErrorMessage()' not activating.</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/toolvalidator-seterrormessage-not-activating/m-p/1566216#M91019</link>
      <description>&lt;P&gt;Thank you. Some examples did (seem to?) set error messages in other methods, but only the updateMessages method worked for me. Also,&amp;nbsp;&lt;EM&gt;combining&lt;/EM&gt; with updateParameters was necessary. The validator class is a little more complicated than I thought, and error messaging - with dynamic responsiveness - will take a little time to figure out. Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 14:45:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/toolvalidator-seterrormessage-not-activating/m-p/1566216#M91019</guid>
      <dc:creator>RandyMcGregor_BMcD</dc:creator>
      <dc:date>2024-12-09T14:45:49Z</dc:date>
    </item>
  </channel>
</rss>

