Hi,
We are having problems when we want to update the field defintion on a featurelayer that is hosted on a featureservice in ArcGIS Online. We want to update the domain definition on multiple fields that uses the same domain.
Domain defintion:
"domain": {
"type": "codedValue",
"name": "YESNO",
"mergePolicy": "esriMPTDefaultValue",
"splitPolicy": "esriSPTDefaultValue",
"codedValues": [
{
"name": "No",
"code": "1"
},
{
"name": "Yes",
"code": "2"
}
]
}This domain is used on multiple fields in a feature layer that is hosted in ArcGIS Online.
We call the update_definition in Python like this:
from arcgis.gis import GIS
import arcgis
import json
gis = GIS([AGOLURL], [USER], [PWD])
fs = arcgis.features.FeatureLayer([FeatureServiceURL], gis)
update_dict = json.loads(...json field defintion...)
check = fs.manager.update_definition(update_dict)JSON field defintion:
"fields": [
{
"name": "field1",
"domain": {
"type": "codedValue",
"name": "YESNO",
"mergePolicy": "esriMPTDefaultValue",
"splitPolicy": "esriSPTDefaultValue",
"codedValues": [
{
"name": "No",
"code": "1"
},
{
"name": "Yes",
"code": "2"
}
]
}
},
{
"name": "field2",
"domain": {
"type": "codedValue",
"name": "YESNO",
"mergePolicy": "esriMPTDefaultValue",
"splitPolicy": "esriSPTDefaultValue",
"codedValues": [
{
"name": "No",
"code": "1"
},
{
"name": "Yes",
"code": "2"
}
]
}
},
{
"name": "field3",
"domain": {
"type": "codedValue",
"name": "YESNO",
"mergePolicy": "esriMPTDefaultValue",
"splitPolicy": "esriSPTDefaultValue",
"codedValues": [
{
"name": "No",
"code": "1"
},
{
"name": "Yes",
"code": "2"
}
]
}
}
]The result from that call is SUCCESS and it updates all fields.
BUT the name of the domain for each field changes from what I except "YESNO" to field1_[number], field2_[number], and so on.
Does anyone have some input how to solve this? or if I am missing something. I have checked that we dont have missed out any fields in the feaure layer that uses the same domain.
We have ArcGIS Pro 3.1.3 installed at the moment.
Solved! Go to Solution.
I've had the same experience. It seems that in ArcGIS Online, a field's domain is defined within the field's definition, meaning a domain only applies to that one field. You cannot re-use one domain across multiple fields in a hosted feature layer, like you might be used to doing in ArcGIS Pro, such as with a feature class in a file geodatabase.
(Intriguingly, there are a couple JSON keys in a typical feature service definition, hasSharedDomains and supportsSharedDomains, which might hint at the possibility of sharing domains across multiple fields? However, I have not found any documentation that describes how to use them.)
I've had the same experience. It seems that in ArcGIS Online, a field's domain is defined within the field's definition, meaning a domain only applies to that one field. You cannot re-use one domain across multiple fields in a hosted feature layer, like you might be used to doing in ArcGIS Pro, such as with a feature class in a file geodatabase.
(Intriguingly, there are a couple JSON keys in a typical feature service definition, hasSharedDomains and supportsSharedDomains, which might hint at the possibility of sharing domains across multiple fields? However, I have not found any documentation that describes how to use them.)
One day these shared domains might come into fruition. For now, each domain for that layer must have a unique name, so AGOL is probably noticing that you are breaking that rule and renaming the domains for you.
Thank you for the tip on hasSharedDomains and supportsSharedDomains in the service definition. When i set them to true it worked 😀.
I have tested on a hosted feature service with multiple layers with fields where they all share the same domain and it works.