Select to view content in your preferred language

Sort or Filter by Retiring Items in AGOL

190
4
11-21-2024 01:37 PM
Status: Open
Teresa_Blader
Frequent Contributor

Since Esri's recent app retirement announcement for ArcGIS Online, I've been combing through our organization trying to figure out what sort of workload we've got amongst all of our users. Web AppBuilder was easy enough using the Web AppBuilder filter.

For the rest, there's a "Web app" filter, however this some includes Instant Apps for some reason and community analyst components. Not sure why Instant Apps show up, since Instant Apps has it's own filter. So that's not super helpful.

So it'd be nice if there was a filter to find the items that are facing retirement like classic story maps and maps designed using Map Viewer Classic that have yet to be saved in Map Viewer.

Teresa_Blader_0-1732224874706.png

 

4 Comments
JRhodes

This script might help:

 

 

from arcgis.gis import GIS

gis = GIS("home")

classic_webmaps = []
classic_storymaps = []
web_appbuilder_apps = []
classic_configurable_apps = []

all_items = gis.content.search(query='', item_type='Map', max_items=10000) # item_type = 'Map' gets both Web Map and Web Mapping Application items

for item in all_items:
    if item.type == "Web Map":
        if not "ArcGIS API for JavaScript" in item.typeKeywords: # this keyword may indicate 4x map
            classic_webmaps.append(item)

    if item.type == "Web Mapping Application":
        if "Story Map" in item.typeKeywords and not "StoryMap" in item.typeKeywords: # keyword 'Story Map' (with a space) indicates classic Story Map
            classic_storymaps.append(item)
        if any(keyword in item.typeKeywords for keyword in ["Web AppBuilder", "WAB2D"]):
            web_appbuilder_apps.append(item)
        if not any(keyword in item.typeKeywords for keyword in ["Web AppBuilder", "WAB2D", "configurableApp", "Ready To Use"]):
            classic_configurable_apps.append(item)

print(f"--------\nThe following {len(classic_webmaps)} web maps may not have been saved in the new Map Viewer:\n")
for map in classic_webmaps:
    print(f"{map.title} ({map.id})")
            
print(f"\n--------\nThe following {len(classic_storymaps)} apps may be classic/3x Story Maps:\n")
for app in classic_storymaps:
    print(f"{app.title} ({app.id})")
    
print(f"\n--------\nThe following {len(web_appbuilder_apps)} apps are Web AppBuilder apps:\n")
for app in web_appbuilder_apps:
    print(f"{app.title} ({app.id})")
        
print(f"\n--------\nThe following {len(classic_configurable_apps)} apps may be classic/3x configurable apps:\n")
for app in classic_configurable_apps:
    print(f"{app.title} ({app.id})")

 

 

Teresa_Blader

Thank you!! But unfortunately I have no experience with running scripts really... is this something you run in ArcGIS Notebooks or where is this script running?? 😮

Teresa_Blader

Ok, I think I figured it out for ArcGIS Notebooks. For my documentation I really need to see who is the owner, when it was last modified, what type of item it is, the full url, and who it's currently shared with... so basically everything that displays when searching content normally.

 

I assume I just add whatever those items are to the print output??

JRhodes

Try this. It will create a CSV item in your portal with the additional information. Yes, running in a Notebook is probably easiest if you're not familiar with Python.

Please note that it's not guaranteed that this will get all 3x items, and it may get some that are not relevant. Esri doesn't have documentation on how these are defined by keyword, so this is my attempt based on what I see in the portals I use.

 

import pandas as pd
from arcgis.gis import GIS
import time

gis = GIS("home")

classic_webmaps = []
classic_storymaps = []
web_appbuilder_apps = []
classic_configurable_apps = []

all_items = gis.content.search(query='', item_type='Map', max_items=10000) # item_type = 'Map' gets both Web Map and Web Mapping Application items

for item in all_items:
    if item.type == "Web Map":
        if not "ArcGIS API for JavaScript" in item.typeKeywords:  # this keyword may indicate 4x map
            classic_webmaps.append(item)

    if item.type == "Web Mapping Application":
        if "Story Map" in item.typeKeywords and not "StoryMap" in item.typeKeywords:  # keyword 'Story Map' (with a space) may indicate classic Story Map
            classic_storymaps.append(item)
        if any(keyword in item.typeKeywords for keyword in ["Web AppBuilder", "WAB2D"]):
            web_appbuilder_apps.append(item)
        if not any(keyword in item.typeKeywords for keyword in ["Web AppBuilder", "WAB2D", "configurableApp", "Ready To Use"]): # 'configurableApp' and 'Ready to Use' may indicate 4x instant app, so we are excluding these
            classic_configurable_apps.append(item)

export_data = []

def add_items_to_export(items):
    for item in items:
        export_data.append({
            "Title": item.title,
            "ID": item.id,
            "Owner": item.owner,
            "URL": item.url or "N/A",
            "Modified": item.modified,
            "Type": item.type,
            "Shared With": item.sharing.shared_with
        })

add_items_to_export(classic_webmaps)
add_items_to_export(classic_storymaps)
add_items_to_export(web_appbuilder_apps)
add_items_to_export(classic_configurable_apps)

df = pd.DataFrame(export_data)
csv_path = f"arcgis\\home\\categorized_items_{int(time.time())}.csv"
df.to_csv(csv_path, index=False)
    
csv_properties = {
    "title": f"Potential_Retiring_Items_{int(time.time())}",
    "type": "CSV",
}

csv_item = gis.content.add(item_properties=csv_properties, data=csv_path)

print(f"CSV item created: {csv_item.title} (ID: {csv_item.id})")