Problem: I have a point feature and reference layer that I use in multiple maps for different crews. The form associated with it in Field Maps Designer is somewhat complicated and I have to remake the form for each new map I put that point and background layer in. This is a pain and also prone to errors and inconsistencies.
I have the following code that copies over the layer I want from the operationallayers of a map that has been configured in Field Maps Designer, to a blank map. It looks correct as far as I can tell and in Field Maps Designer on the new map all of the calculations are the same. BUT the blue plus button is not present in the Field Maps App for the new map and I cannot collect the point feature like I can in the original map.
from arcgis.gis import GIS
import json
gis = GIS('home')
source_web_map_id = 'xy'
dest_web_map_id = 'xy'
# get underlying data for the webmaps as a dictionary
#Source webmap with field maps configured
src_wm_item = gis.content.get(source_web_map_id)
src_wm_data = src_wm_item.get_data()
# blank new webmap
dest_wm_item = gis.content.get(dest_web_map_id)
dest_wm_data = dest_wm_item.get_data()
for layer in src_wm_data.get("operationalLayers"):
if layer.get("title") in ['Layer 1 Name', "Layer 2 Name"]:
dest_wm_data["operationalLayers"].append(layer)
# Create the item_properties dictionary with the updated JSON
item_properties = {"text": json.dumps(dest_wm_data)}
# Update the web map item with the new JSON definition
update_result = dest_wm_item.update(item_properties=item_properties)
print(update_result)
Can anyone help me figure out what I am missing?