Hi,
I just wondered: is there a limitation on the number of views you can create on a Hosted Feature Layer? In ArcGIS Online and/or in Portal for ArcGIS?
On this page (Create hosted feature layer views—Portal for ArcGIS | ArcGIS Enterprise) it is stated that
You can create a maximum of 20 views from the same hosted feature layer.
whereas on this page (Create hosted feature layer views—ArcGIS Online Help | ArcGIS) this limitation seems absent (although there is a limit of 20 to the number of categories you can assign to the item....)
And this limitation of 20 views on a Hosted Feature Layer in Portal for ArcGIS Enterprise, is that just a limitation of the UI which can be circumvented using a Python script, as kimberly peter states on GitHub (Add information and a sample for creating hosted feature layer views using Python · Issue #340 · Esri/arcgis-python-api … )?
With the Python script below I can create 25 views on a Hosted Feature Layer in ArcGIS Online. Would a similar approach be possible in Portal for ArcGIS Enterprise?
TIA,
Egge-Jan
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> GIS
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>features <SPAN class="keyword token">import</SPAN> FeatureLayerCollection
<SPAN class="keyword token">from</SPAN> provide_credentials <SPAN class="keyword token">import</SPAN> provide_credentials
username<SPAN class="punctuation token">,</SPAN> password <SPAN class="operator token">=</SPAN> provide_credentials<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
my_agol <SPAN class="operator token">=</SPAN> GIS<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"https://www.arcgis.com"</SPAN><SPAN class="punctuation token">,</SPAN> username<SPAN class="punctuation token">,</SPAN> password<SPAN class="punctuation token">)</SPAN>
service <SPAN class="operator token">=</SPAN> my_agol<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"<serviceItemId_of_your_Hosted_Feature_Layer>"</SPAN><SPAN class="punctuation token">)</SPAN>
flc <SPAN class="operator token">=</SPAN> FeatureLayerCollection<SPAN class="punctuation token">.</SPAN>fromitem<SPAN class="punctuation token">(</SPAN>service<SPAN class="punctuation token">)</SPAN>
clients <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'ONE'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'TWO'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'THREE'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'FOUR'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'FIVE'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'SIX'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'SEVEN'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'EIGHT'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'NINE'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'TEN'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'ELEVEN'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'TWELVE'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'THIRTEEN'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'FOURTEEN'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'FIFTEEN'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'SIXTEEN'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'SEVENTEEN'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'EIGHTEEN'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'NINETEEN'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'TWENTY'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'TWENTY-ONE'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'TWENTY-TWO'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'TWENTY-THREE'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'TWENTY-FOUR'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'TWENTY-FIVE'</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">for</SPAN> client <SPAN class="keyword token">in</SPAN> clients<SPAN class="punctuation token">:</SPAN>
view_name <SPAN class="operator token">=</SPAN> service<SPAN class="punctuation token">.</SPAN>name <SPAN class="operator token">+</SPAN> <SPAN class="string token">"_View_"</SPAN> <SPAN class="operator token">+</SPAN> client
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>view_name<SPAN class="punctuation token">)</SPAN>
view <SPAN class="operator token">=</SPAN> flc<SPAN class="punctuation token">.</SPAN>manager<SPAN class="punctuation token">.</SPAN>create_view<SPAN class="punctuation token">(</SPAN>name<SPAN class="operator token">=</SPAN>view_name<SPAN class="punctuation token">,</SPAN> spatial_reference<SPAN class="operator token">=</SPAN>None<SPAN class="punctuation token">,</SPAN> extent<SPAN class="operator token">=</SPAN>None<SPAN class="punctuation token">,</SPAN> allow_schema_changes<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> updateable<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> capabilities<SPAN class="operator token">=</SPAN><SPAN class="string token">'Query, Update'</SPAN><SPAN class="punctuation token">,</SPAN> view_layers<SPAN class="operator token">=</SPAN>None<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> lyr <SPAN class="keyword token">in</SPAN> view<SPAN class="punctuation token">.</SPAN>layers<SPAN class="punctuation token">:</SPAN>
query <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Description = '%s'"</SPAN><SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>client<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>query<SPAN class="punctuation token">)</SPAN>
lyr<SPAN class="punctuation token">.</SPAN>manager<SPAN class="punctuation token">.</SPAN>update_definition<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">'viewDefinitionQuery'</SPAN><SPAN class="punctuation token">:</SPAN> query<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>