What is the maximum number of views on a Hosted Feature Layer?

03-14-2019 02:36 PM
MVP Regular Contributor


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 · Esr... )?

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?



from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection
from provide_credentials import provide_credentials

username, password = provide_credentials()
my_agol = GIS("https://www.arcgis.com", username, password)

service = my_agol.content.get("<serviceItemId_of_your_Hosted_Feature_Layer>")

flc = FeatureLayerCollection.fromitem(service)

clients = ['ONE','TWO','THREE','FOUR','FIVE','SIX',

for client in clients:
    view_name = service.name + "_View_" + client
    view = flc.manager.create_view(name=view_name, spatial_reference=None, extent=None, allow_schema_changes=True, updateable=True, capabilities='Query, Update', view_layers=None)
    for lyr in view.layers:
        query = "Description = '%s'"%(client)
        lyr.manager.update_definition({'viewDefinitionQuery': query})
3 Replies
Esri Regular Contributor

There is a property in the service json definition (of the source feature service) called "maxViewsCount". By default this is set to 20 for performance reasons especially when fields on the source feature service are modified and the changes need to be propagated to the views. However, you can call updateDefinition on the feature service (not the layer) to modify this value. I believe this is only a limitation for ArcGIS Enterprise but don't quote me on that.

If you try to create more views than the maxViewsCount, you will get an error returned from the server. 

MVP Regular Contributor

OK - Tnx. Will investigate and get back to you to mark this as the right answer as soon as I have confirmed this for myself :)

0 Kudos
New Contributor III


we have one master feature layer with admin boundaries for all countries and territories in the world, including subnational boundaries. We needed separate views with a subset of boundaries for each country, which makes it ~260 views created based on the same source feature layer. I was able to create all views using ArcGIS Python API, though had to run the script a few times due to timeouts etc.

PS. I can't find 'maxViewsCount' property in JSON definition of the source feature service. Has this been removed..?

The question to others: what was the max number of Views that you've created on AGOL? Any performance issues or other implications?



0 Kudos