ArcPy - Get list of layers used in an AGOL Dashboard

835
2
08-20-2020 09:42 AM
Michael_Knapp
New Contributor III

Hi Folks - 

 

I'm trying to get a list of the layers used in our organization's dashboard via Python.

 

I can get a list of the dashboard without a problem:

 

for item in gis.content.search(query="NOT owner:esri_livingatlas",item_type="Dashboard", max_items=maxItems):
row = (item.title,item.owner,item.access,item.id,site,pubdate)
print('Dashboard:',row)
dashCursor.insertRow(row)

dashID = item.id
dashTitle = item.title
dashOwner = item.owner

 

But am thrown off by the fact that I can't just modify the code that we've use to get layers from a web map:

imap = WebMap(item)
layer_list = wmo.definition['operationalLayers']
layer_list = imap.layers

Is there something analogous that we can use for Dashboards? Have looked through help docs, but nothing yet. 

 

Thanks!

2 Replies
Tom_Laue
New Contributor III

Christina Miller I was trying to do the exact same thing as you when I found your post.  I’m just shocked ESRI doesn’t provide these kinds of reports out of the box.

I spent many hours trying to figure out how to read the webmapID in a given app/dashboard with Python (which I could see in AGOL Assistant JSON view).  Luckily, I eventually found the solution: See line In [13]:

https://developers.arcgis.com/python/guide/cloning-content/    

Attached is the script I developed.  It searches your ArcGIS Online for any web apps and dashboards and will then list each of those items and its details, the webmap associated to it and its details, and then every layer in that map and it's URL.

RogerDunnGIS
Occasional Contributor II

I've put in an ArcGIS Idea to make this kind of functionality out-of-the-box.  Please see the following URL and give it a kudos if you agree with it:

https://community.esri.com/t5/arcgis-enterprise-ideas/search-content-by-arcgis-server-url/idi-p/1154...

 

0 Kudos