Clone Dashboard with New Web Map: Other Widgets don't Update

08-23-2021 06:47 PM
New Contributor III

I am in the process of cloning a number of dashboards for several organizations. I have created new web maps that need to be included within the cloned dashboards. In other words, when I clone, I'm swapping out the web maps that were originally in the dashboards and replacing them with new web maps.

I'm able to clone the dashboard and replace the old maps with the new maps; however, all of the other widgets are broken when I run the clone process (i.e., I'm getting a Data Source Error and the widgets are not able to access the data):


To figure out the best way to run my clone operation, I watched the following video:

My code to try to get this working is here:

# import libraries
from arcgis.gis import GIS

# connect to GIS org
gis = GIS(url, username, password)

# get the dashboard to be cloned by item ID
dash = gis.content.get("6c698f1b477645c381ffda09b9dac0b8")
dash_name = dash.title

# get existing map widget item ID
dash_map = [w for w in dash.get_data()['widgets'] if w['type'] == 'mapWidget'][0]

# create Python dictionary object to hold the web map items ids for the old WM and the new WM
# Key - old web map item id
# Value - new web map item id (new web map item ID is hard coded for now)
wm_mapping = {dash_map['itemId']: '351fa7da899c491ba061692dc785259f'}

# clone the dashboard while substituting the new web map (wm_mapping VALUE) in for the old web map (wm_mapping KEY)
cloned_dash_item = gis.content.clone_items(items=[dash], folder="zz_ClonedAppsWithUpdatedWebMaps", item_mapping=wm_mapping)

print(f'finished cloning {dash_name} dashboard')


Is there something I'm missing? Do I need to include the other widgets in my item mapping dictionary (line 18)? I made sure that the name of the layers that "feed" the various widgets didn't change between the old and the new web maps in case that would cause the widgets to break.

Any help is appreciated.

Tags (2)
0 Kudos
0 Replies