Hi
I have been trying to delete a field from a feature layer. I have tried "delete_from_definition" and I get a success response, and yet the field (column) is still there afterwards:
1. I have a layer object, named updater_layer (it is definitely a feature layer object, I have checked its properties).
2. I create the JSON that defines the column:
status_remove = {
"name" : "STATUS",
"type" : "esriFieldTypeString",
"alias" : "Status",
"sqlType" : "sqlTypeOther",
"length" : 35,
"nullable" : 'true',
"editable" : 'true',
"domain" : 'null',
"defaultValue" : 'null'
}
3. I use:
updater_layer.manager.delete_from_definition(status_remove)
{'success': True}
but when I look at the properties i.e.
updater_layer.manager.properties
The STATUS field is still there.
How do I remove a field from a feature layer in ArcGIS Online using the arcgis.gis API?
Thanks
Hugo
Hello Hugo,
Here is how you would delete a field from a feature layer hosted in AGOL.
import arcgis
from arcgis.gis import GIS
# Provide credentials to the GIS object.
gis = GIS(username="your username", password= "your password")
#Get the id of the hosted feature layer
item = gis.content.get("id to the feature layer")
#Get the actual feature layer
fl = item.layers[0]
#This is the JSON structure you need to pass in so that it knows what field to delete.
# https://developers.arcgis.com/rest/services-reference/delete-from-definition-feature-layer-.htm
json = {
"fields" : [
{
"name" : "POP90_SQMI"
}
]
}
result = fl.manager.delete_from_definition(json)
print(result)
i am sorry an still new in this. Where i can run this code. can you please tell me what to do.