HOW TO
As of the June 2018 ArcGIS Online update, domains can be added and updated in ArcGIS Online through the Data tab on the hosted feature layer's item page. For more details, refer to ArcGIS Online: Define attribute lists and ranges.
Edits to read-only domains of a hosted feature layer can be made by running a Python script in ArcGIS Pro and this article provides the workflow.
Note: The workflow below changes the domain name, code, and code value as examples.
import arcgis
gis = arcgis.gis.GIS('https://www.arcgis.com', 'Username', 'Password')
url = 'the hosted feature layer URL'
fs = arcgis.features.FeatureLayer(url, gis)
update_dict ={'fields':[{'name':'field_name','domain':{'type':'codedValue','name':'domain_name','codedValues':[{'name':'code name','code':'code value'},{'name':'code name2','code':'code value2'},{'name':'code name3','code':'code value3'},{'name':'code name4','code':'code value4'},{'name':'code name5','code':'code value5'},{'name':'code name6','code':'code value6'},{'name':'code name7','code':'code value7'}]}}]}
fs.manager.update_definition(update_dict)
The following code block demonstrates the full working script.
import arcgis gis = arcgis.gis.GIS('https://www.arcgis.com', 'Username', 'Password') url = 'https://services.arcgis.com/Wl7Y1m92PbjtJs5n/arcgis/rest/services/Domain_Art_Test/FeatureServer/0' fs = arcgis.features.FeatureLayer(url, gis) update_dict ={'fields':[{'name':'Asia','domain':{'type':'codedValue','name':'Asia','codedValues':[{'name':'Tokyo, Japan','code':1},{'name':'Jakarta, Indonesia','code':2},{'name':'Kuala Lumpur, Malaysia','code':3},{'name':'Beijing, China','code':4},{'name':'Hanoi, Vietnam','code':5},{'name':'Manila, Philippines','code':6},{'name':'Seoul, South Korea','code':7}]}}]} fs.manager.update_definition(update_dict)
The image below shows the updated read-only hosted feature layer domains using Python for ArcGIS Pro.
Article ID: 000027789
Get help from ArcGIS experts
Download the Esri Support App