Search for Views Created from a User Provided Feature Layer

125
3
Jump to solution
01-20-2022 12:02 PM
JaimieNevins2
New Contributor II

 

Looking for a way to query all the Views created from a provided Feature Layer.  In AGOL, this information is provided on the Overview page under the Details : Other Views (see below).  How do I access this  data using ArcGIS API for Python?

Thanks in advanced!

JaimieNevins2_0-1642708724674.png

 

0 Kudos
1 Solution

Accepted Solutions
MehdiPira1
Esri Contributor

Hi @JaimieNevins2 ,

Here's a sample script which lists all the layer views of a hosted feature layer:

from arcgis import GIS
from arcgis.features import FeatureLayerCollection

gis = GIS("portal_url", "username", "password")

source_item = gis.content.search("feature_layer")[0]
flc = FeatureLayerCollection.fromitem(source_item)
for view in flc.layers[0].manager.properties.adminLayerInfo.layerViews:
    print(view.serviceName)

 

Hope that helps.

Mehdi

View solution in original post

3 Replies
MehdiPira1
Esri Contributor

Hi @JaimieNevins2 ,

Here's a sample script which lists all the layer views of a hosted feature layer:

from arcgis import GIS
from arcgis.features import FeatureLayerCollection

gis = GIS("portal_url", "username", "password")

source_item = gis.content.search("feature_layer")[0]
flc = FeatureLayerCollection.fromitem(source_item)
for view in flc.layers[0].manager.properties.adminLayerInfo.layerViews:
    print(view.serviceName)

 

Hope that helps.

Mehdi

JaimieNevins2
New Contributor II

Thank you so much!

0 Kudos
MehdiPira1
Esri Contributor

Not a problem @JaimieNevins2.

If my reply has answered your question, could you please Accept as Solution?

Thanks.