<?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: Setting Field Visibility in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/setting-field-visibility/m-p/98533#M7651</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey Josh,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That's true, I didn't notice that. Interesting thing is that the intellisense in the python window suggests setvisible, not setVisible.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I changed it anyway, but still no dice.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It doesn't throw an exception in either case which is also strange.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;would&lt;/SPAN&gt;&lt;SPAN&gt; be really cool if it worked. lol. Would be nice to be able to turn fields off prior to an export in order to omit them from the result.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Apr 2014 17:03:48 GMT</pubDate>
    <dc:creator>JohnDye</dc:creator>
    <dc:date>2014-04-24T17:03:48Z</dc:date>
    <item>
      <title>Setting Field Visibility</title>
      <link>https://community.esri.com/t5/python-questions/setting-field-visibility/m-p/98531#M7649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Anyone know how to make fields in a Feature Layer visible or hidden?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tried using the Field Info object, no luck there...&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;desc = arcpy.Describe("FeatureLayer") field_info = desc.fieldInfo visibleFields = ["ID", "NAME", "Rank", "Count"] for index in xrange(0, field_info.count): &amp;nbsp;&amp;nbsp;&amp;nbsp; fieldName = str(field_info.getfieldname(index)) &amp;nbsp;&amp;nbsp;&amp;nbsp; if fieldName in visibleFields: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Found Field " + str(fieldName) + " in visibleFields. Setting Visible..." &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; field_info.setvisible(index, "VISIBLE") &amp;nbsp;&amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Field " + str(fieldName) + " not found in visibleFields. Setting Hidden..." &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; field_info.setvisible(index, "HIDDEN")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tried tossing a RefreshActiveView() onto the end, that didn't help either.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Apr 2014 16:18:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-field-visibility/m-p/98531#M7649</guid>
      <dc:creator>JohnDye</dc:creator>
      <dc:date>2014-04-24T16:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Field Visibility</title>
      <link>https://community.esri.com/t5/python-questions/setting-field-visibility/m-p/98532#M7650</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello John,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cool script. I haven't seen that before.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure if this will help, but the help documentation uses "setVisible" (not "setvisible"). Same for "getFieldName".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good luck!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;~Josh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Apr 2014 16:41:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-field-visibility/m-p/98532#M7650</guid>
      <dc:creator>JoshuaChisholm</dc:creator>
      <dc:date>2014-04-24T16:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Field Visibility</title>
      <link>https://community.esri.com/t5/python-questions/setting-field-visibility/m-p/98533#M7651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey Josh,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That's true, I didn't notice that. Interesting thing is that the intellisense in the python window suggests setvisible, not setVisible.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I changed it anyway, but still no dice.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It doesn't throw an exception in either case which is also strange.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;would&lt;/SPAN&gt;&lt;SPAN&gt; be really cool if it worked. lol. Would be nice to be able to turn fields off prior to an export in order to omit them from the result.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Apr 2014 17:03:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-field-visibility/m-p/98533#M7651</guid>
      <dc:creator>JohnDye</dc:creator>
      <dc:date>2014-04-24T17:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Field Visibility</title>
      <link>https://community.esri.com/t5/python-questions/setting-field-visibility/m-p/98534#M7652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Like this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/98415-Turn-fields-off-by-script?p=349972#post349972"&gt;http://forums.arcgis.com/threads/98415-Turn-fields-off-by-script?p=349972#post349972&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Apr 2014 17:10:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-field-visibility/m-p/98534#M7652</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2014-04-24T17:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Field Visibility</title>
      <link>https://community.esri.com/t5/python-questions/setting-field-visibility/m-p/98535#M7653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You're definitely on the right track there.&amp;nbsp; I ran into this problem a couple months ago.&amp;nbsp; The key is that field info is a read only attribute, you can't write setvisibility on field in an existing feature layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The general workflow is like you have it above.&amp;nbsp; Make your field info object base on your existing feature layer, then you want to make a new feature layer using the optional "field_info" attribute.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000006p000000" rel="nofollow" target="_blank"&gt;Make Feature Layer (Data Management) &lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here my code for that.&amp;nbsp; I took your code and simplified it just a little.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;visibleFields = ["ID", "NAME", "Rank", "Count"] field_info = arcpy.Describe("FeatureLayer").fieldInfo for index in xrange(0, field_info.count): &amp;nbsp;&amp;nbsp;&amp;nbsp; if field_info.getfieldname(index) not in visibleFields: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; field_info.setvisible(index,"HIDDEN")&amp;nbsp; arcpy.MakeFeatureLayer_management("FeatureLayer","Feature_Layer_With_New_Visibilities","","",field_info)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you have symbology and/or labeling, this can mess with that too.&amp;nbsp; If you're having issues with that, I can dig up a code example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Apr 2014 18:56:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-field-visibility/m-p/98535#M7653</guid>
      <dc:creator>MattEiben</dc:creator>
      <dc:date>2014-04-24T18:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Field Visibility</title>
      <link>https://community.esri.com/t5/python-questions/setting-field-visibility/m-p/98536#M7654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Wayne_Whitley!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was just about to reference my own post and you beat me to it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Apr 2014 18:57:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-field-visibility/m-p/98536#M7654</guid>
      <dc:creator>MattEiben</dc:creator>
      <dc:date>2014-04-24T18:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Field Visibility</title>
      <link>https://community.esri.com/t5/python-questions/setting-field-visibility/m-p/98537#M7655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;The general workflow is like you have it above.&amp;nbsp; Make your field info object base on your existing feature layer, then you want to make a new feature layer using the optional "field_info" attribute.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Matt &amp;amp; Wayne, I got it going now. Good to know that an export is required.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Geeze ESRI, I don't even have words for this nonsense. This is so not neccesary...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Apr 2014 19:29:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-field-visibility/m-p/98537#M7655</guid>
      <dc:creator>JohnDye</dc:creator>
      <dc:date>2014-04-24T19:29:10Z</dc:date>
    </item>
  </channel>
</rss>

