@DougGreen That's awesome that you say it's fixed....unfortunately, I didn't experience the same behavior when I was working on this yesterday.
I wanted to share what I ended up doing, after lots of trial and error, which seemed to work. Below is a snippet from the script for the tool I built.
try:
# Add layer definition from JSON file to the service definition
result = fs.manager.add_to_definition(config)
if result.get("success"):
arcpy.AddMessage("Layer successfully added.")
# Update the item metadata with the new layer so it appears in the AGOL UI
item.update(data={"layers": [dict(layer.properties) for layer in fs.layers]})
else:
arcpy.AddWarning(f"Failed to add layer. Response: {result}")
I found that I needed to use item.update, specifically using a dictionary structure like that, to properly get the item metadata to update to match the service definition.
How did you handle your workflow, in which you say it updated the item details automatically?
A potentially important detail, I was working with a hosted feature layer that was published from ArcGIS Pro. I believe the metadata for these is structured slightly differently compared to hosted feature layers created in ArcGIS Online directly. Perhaps that was a factor....
Best,
Katie
If this answer helped you, please consider giving a kudos and/or marking as the accepted solution. Thanks!