Feature Service 'Add to Definition' update domain

2026
4
Jump to solution
09-05-2018 01:05 AM
StuartMoore
Occasional Contributor III

Hi,

can i use the 'Add to Definition' REST api to update a domain on a feature service, i want to add in an additional value into the domain

Stu

0 Kudos
1 Solution

Accepted Solutions
KellyGerrow
Esri Frequent Contributor

You can also add coded value domains through a list of values from the data tab in ArcGIS Online. Check out these resources for more information:

Define attribute lists and ranges—ArcGIS Online Help | ArcGIS 

https://www.esri.com/arcgis-blog/products/arcgis-online/uncategorized/whats-new-with-managing-field-... 

View solution in original post

0 Kudos
4 Replies
MarisaClaggett
Occasional Contributor II

Hi Stuart,

You will have to use the Update definition operation.  I have included a link to a very helpful document outlining what can be updated via this definition, including domain values.

How To: Add coded value domains to a hosted feature service from a REST endpoint 

Hope this helps!

Best,

Marisa

KellyGerrow
Esri Frequent Contributor

You can also add coded value domains through a list of values from the data tab in ArcGIS Online. Check out these resources for more information:

Define attribute lists and ranges—ArcGIS Online Help | ArcGIS 

https://www.esri.com/arcgis-blog/products/arcgis-online/uncategorized/whats-new-with-managing-field-... 

0 Kudos
TheKenerson
Occasional Contributor

Hi,

    I was looking to define an attribute list using ArcGIS API for Python. I would think its a function tied to the Feature_Layer Object, but I cant seem to find it. The furthest i get is......

from arcgis.features import FeatureLayer
layer_url = 'https://servername.arcgis.com/OrrtI/arcgis/rest/services/TreeWorks/FeatureServer/0'

 layer = FeatureLayer(layer_url)

# Do a loop through all the fields in  the feature layer
for f in layer.properties.fields:
    print(f['name'])

This will get me to the feature layer field names but not sure where to go from there.

0 Kudos
StuartMoore
Occasional Contributor III

this might help

Stu

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import arcpy 
from arcpy import env 
import os 


env.workspace = "h:\Connection.sde"

datasets = arcpy.ListDatasets("*", "All")

# Write the name of the current fc in text file:
txtFileFC = open("H:\ListAll_FC.txt","w")
txtFileFC.write('Dataset|Type|FeatureClass Name|Record Count')
txtFileFC.write (os.linesep)

# Write the name of the current fields fc in text file:
txtFileFields = open("H:\ListAll_Fields.txt","w")
txtFileFields.write('Dataset|Type|FeatureClass Name|Field Name|Alias Name|Data Type|Required|Length|Domain')
txtFileFields.write (os.linesep)

# Write the name of Domains text file:
txtFileDomains = open("H:\ListAll_Domains.txt","w")
txtFileDomains.write('Domain Name|Domain Type|Coded Value|Alias Name|Min Range|Max Range')
txtFileDomains.write (os.linesep)

##----------------------------------
## List Features in Datasets

for dataset in datasets:
    for fc in arcpy.ListFeatureClasses('','',dataset):
        RecCount= '0'
##--- uncomment for counts
        arcpy.MakeTableView_management(fc, "myTableView")
        RecCount = arcpy.GetCount_management("myTableView").getOutput(0)
        arcpy.Delete_management("myTableView")
##--- uncomment for counts
        
        # Write messages to a Text File
        txtFileFC.write(dataset+'|FC|'+fc+'|'+RecCount)
        txtFileFC.write (os.linesep)
        for field in arcpy.ListFields(fc):
            # Write messages to a Text File
            txtFileFields.write(dataset+'|FCField|'+fc+'|'+format(field.name)+'|'+format(field.aliasName)+'|'+format(field.type)+'|'+format(field.required)+'|'+format(field.length)+'|'+format(field.domain))
            txtFileFields.write (os.linesep)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
##----------------------------------        

#close text file
txtFileFields.close()
txtFileFC.close()
0 Kudos