"Easy" depends on how comfortable you are with directly editing a service's JSON and using Python.
To do this, you'll need to access the managers submodule of the arcgis.features module, and specifically the FeatureLayerManager class. Here's what it might look like:
from arcgis import GIS
gis = GIS('portal-url', 'user', 'pw')
src_layer = gis.content.get('itemID').layers[0]
src_props = src_layer.manager.properties
The object returned by properties will be a dict akin to the JSON you see in the REST directory. If you look through it, you'll see a section that looks like this:
{
...
"fields": [
...
{
"name": "the-field-you-want",
...
"domain": {
"type": "codedValue",
"name": "booleanExample",
"codedValues": [
{
"name": "Yes",
"code": 1
},
{
"name": "No",
"code": 0
}
]
},
...
],
...
}
So what we'll do is copy the contents of the domain key out. Then we can use another manager function, update_definition, to update the other layers. Here's the rest of the Python:
domain_dict = src_props['fields'][index-of-the-field-you-want]['domain']
dest_lyrs = [list, of, layers]
update_dict = {
"fields": [
"name": "destination-field-name",
"domain": domain_dict
]
}
for lyr in dest_lyrs:
lyr.manager.update_definition(update_dict)
Now, the field you're updating might change layer to layer, so perhaps this can't be done in iteration. That'll depend on your situation. You could probably roll this all up into a custom function, too.
- Josh Carlson
Kendall County GIS