<?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 Summarize Unique Values on Parameter Update? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/summarize-unique-values-on-parameter-update/m-p/813460#M2551</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I have a python script that has two parameters&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/431009_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;They are an input feature class and then an input field obtained from that feature class. How would I go about making a third parameter that's a boolean checklist of all unique values from that input field in that feature class, which updates after you select a field? I'd like it to have a checkbox but I recognize that I might have to have a dropdown-&amp;gt;add sort of functionality instead. In the end I'd like to essentially choose values that I want to 'turn on' in a feature class by changing a value&amp;nbsp;of 0 or 1, which I have set up in my python script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;import arcpy&lt;BR /&gt;## This code is to quickly choose which states get the selected color and which ones don't&lt;BR /&gt;inFC = arcpy.GetParameterAsText(0)&lt;BR /&gt;inFld = arcpy.GetParameterAsText(1)&lt;BR /&gt;stateList = arcpy.GetParameter(2)&lt;BR /&gt;## Check to see if it has the Lightswitch field&lt;BR /&gt;fldLst = arcpy.ListFields(inFC)&lt;BR /&gt;fldLst2 = []&lt;BR /&gt;x=0&lt;BR /&gt;for fld in fldLst:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; fldLst2.append(fld.name)&lt;BR /&gt;del fld&lt;BR /&gt;arcpy.AddMessage("It's pitch dark... you are likely to be eaten by a grue...")&lt;BR /&gt;arcpy.AddMessage("&amp;gt;Find lightswitch")&lt;BR /&gt;arcpy.AddMessage("You begin stumbling around in the dark, searching for a lightswitch")&lt;BR /&gt;for fld in fldLst2:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if fld is not 'Lightswitch': ##If the field isn't a lightswitch, add a strike&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x+=1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; elif fld is 'Lightswitch':&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.AddMessage("You found the dang* Lightswitch and turned it on.")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;BR /&gt;&amp;nbsp; &amp;nbsp; elif x == len(fldLst2): ##If the field isn't a lightswitch and you've checked every field, build your own&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.AddMessage("You couldn't find the lightswitch, so instead you decide to build your own")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.AddField_management(inFC,'Lightswitch','SHORT',1)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;BR /&gt;with arcpy.da.UpdateCursor(inFC,[inFld,'Lightswitch']) as cursor:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; for state in cursor:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; state[1]=0 ##Default switch is set to off&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cursor.updateRow(state) &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for stat in stateList: ##Check it against selected states, if it's in the selected state list, turn it on&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if state[0]!=stat:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; continue&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; elif state[0]==stat:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; state[1]=1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cursor.updateRow(state)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Dec 2018 15:26:12 GMT</pubDate>
    <dc:creator>DevonBurton3</dc:creator>
    <dc:date>2018-12-06T15:26:12Z</dc:date>
    <item>
      <title>Summarize Unique Values on Parameter Update?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/summarize-unique-values-on-parameter-update/m-p/813460#M2551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I have a python script that has two parameters&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/431009_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;They are an input feature class and then an input field obtained from that feature class. How would I go about making a third parameter that's a boolean checklist of all unique values from that input field in that feature class, which updates after you select a field? I'd like it to have a checkbox but I recognize that I might have to have a dropdown-&amp;gt;add sort of functionality instead. In the end I'd like to essentially choose values that I want to 'turn on' in a feature class by changing a value&amp;nbsp;of 0 or 1, which I have set up in my python script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;import arcpy&lt;BR /&gt;## This code is to quickly choose which states get the selected color and which ones don't&lt;BR /&gt;inFC = arcpy.GetParameterAsText(0)&lt;BR /&gt;inFld = arcpy.GetParameterAsText(1)&lt;BR /&gt;stateList = arcpy.GetParameter(2)&lt;BR /&gt;## Check to see if it has the Lightswitch field&lt;BR /&gt;fldLst = arcpy.ListFields(inFC)&lt;BR /&gt;fldLst2 = []&lt;BR /&gt;x=0&lt;BR /&gt;for fld in fldLst:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; fldLst2.append(fld.name)&lt;BR /&gt;del fld&lt;BR /&gt;arcpy.AddMessage("It's pitch dark... you are likely to be eaten by a grue...")&lt;BR /&gt;arcpy.AddMessage("&amp;gt;Find lightswitch")&lt;BR /&gt;arcpy.AddMessage("You begin stumbling around in the dark, searching for a lightswitch")&lt;BR /&gt;for fld in fldLst2:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if fld is not 'Lightswitch': ##If the field isn't a lightswitch, add a strike&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x+=1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; elif fld is 'Lightswitch':&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.AddMessage("You found the dang* Lightswitch and turned it on.")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;BR /&gt;&amp;nbsp; &amp;nbsp; elif x == len(fldLst2): ##If the field isn't a lightswitch and you've checked every field, build your own&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.AddMessage("You couldn't find the lightswitch, so instead you decide to build your own")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.AddField_management(inFC,'Lightswitch','SHORT',1)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;BR /&gt;with arcpy.da.UpdateCursor(inFC,[inFld,'Lightswitch']) as cursor:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; for state in cursor:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; state[1]=0 ##Default switch is set to off&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cursor.updateRow(state) &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for stat in stateList: ##Check it against selected states, if it's in the selected state list, turn it on&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if state[0]!=stat:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; continue&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; elif state[0]==stat:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; state[1]=1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cursor.updateRow(state)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Dec 2018 15:26:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/summarize-unique-values-on-parameter-update/m-p/813460#M2551</guid>
      <dc:creator>DevonBurton3</dc:creator>
      <dc:date>2018-12-06T15:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: Summarize Unique Values on Parameter Update?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/summarize-unique-values-on-parameter-update/m-p/813461#M2552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Devon,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the 3rd parameter, set the &lt;STRONG&gt;Data Type&lt;/STRONG&gt; to a &lt;EM&gt;String&lt;/EM&gt;, &lt;STRONG&gt;Multivalue&lt;/STRONG&gt; to &lt;EM&gt;Yes&lt;/EM&gt;, and &lt;STRONG&gt;Filter&lt;/STRONG&gt; to &lt;EM&gt;Value List:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/430996_pastedImage_6.png" /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can then use Validation tab to populate this Value List:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;updateParameters&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;self&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;params&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;value &lt;SPAN class="operator token"&gt;and&lt;/SPAN&gt; self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;params&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;value&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;params&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;filter&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;list &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sorted&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;params&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;value&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;params&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;value&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;value&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will give you the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/431033_pastedImage_7.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:34:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/summarize-unique-values-on-parameter-update/m-p/813461#M2552</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-12T09:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: Summarize Unique Values on Parameter Update?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/summarize-unique-values-on-parameter-update/m-p/813462#M2553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Dec 2018 18:18:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/summarize-unique-values-on-parameter-update/m-p/813462#M2553</guid>
      <dc:creator>DevonBurton3</dc:creator>
      <dc:date>2018-12-06T18:18:51Z</dc:date>
    </item>
  </channel>
</rss>

