Select to view content in your preferred language

Clone items, clone a map and only x layers

71
0
Friday
StuartMoore
Frequent Contributor

i have an experience builder app which has a map and the map has 4 layers in it, i want to clone the app and the map and only 1 of the 4 layers and then to remap the cloned feature service into the cloned map. 

i've tried this but it copies all 4 layers, i even tried the item_mapping and used the same id as both

from pathlib import Path
import sys
import pandas as pd

from arcgis.gis import GIS, Item
from arcgis.env import active_gis
from arcgis.features import FeatureLayerCollection
from arcgis.mapping import WebMap

source = GIS("home")
print(source)
target = GIS("home")
print(target)

group = source.groups.search("id: 8d..fd")[0]

for item in group.content():
    print(item['title'])
    print(item['id'])
    xid = item['id']
    items = source.content.search(query="id:{0}".format(xid))
    #items
    for item in items:
        try:
            print("Cloning " + item.title)
            copy_list = []
            copy_list.append(item)
            
            print (copy_list)
            
            if (item.title == "In_Map"):
                item_mapping = {"db..d77" : "db..d77"}
                target.content.clone_items(copy_list, copy_data=True, search_existing_items=True, item_mapping = item_mapping, folder="In_Map_Test_version")
            else:
                target.content.clone_items(copy_list, copy_data=True, search_existing_items=True,folder="In_Map_Test_version")
            print("Successfully cloned " + item.title)
        except Exception as e:
            print(e)

 any ideas?

Tags (2)
0 Kudos
0 Replies