Hi Kristian,
Please have a look at the sample below.
This works for me:
- Login to ArcGIS Online
- Select the relevant layer of your Hosted Feature Layer
- Create an update_dict with your coded values in the correct order and apply this to the relevant field with update_definition()
Does this answer your question?
Cheers,
Egge-Jan
from arcgis.gis import GIS
from provide_credentials import provide_credentials
username, password = provide_credentials()
my_agol = GIS("https://www.arcgis.com", username, password)
lyr = my_agol.content.get('<HFL_ID>').layers[0]
update_dict = {"fields": [
{
"name": "Color",
"domain": {"type":"codedValue","name":"MY_CODED_VALUE_DOMAIN",
"codedValues":[{"name":"Blue","code":"Blue"},
{"name":"Green","code":"Green"},
{"name":"Orange","code":"Orange"},
{"name":"Red","code":"Red"},
{"name":"Yellow","code":"Yellow"}]}
}
]}
update = lyr.manager.update_definition(update_dict)
print(update)