Hi all,
I have a map viewer containing a single feature service. When I click on the map viewer edit tool and select multiple features, the tool displays the selected features Object IDs. How can I change the field that is displayed in the edit tool to something more user friendly (see image)?
It seems like something that should be easy to do but I have spent ages looking through options on the feature layer and web viewer but can seem to find any way to do this.
Thanks
Lee
Solved! Go to Solution.
Hi @Lee_Butler
You can use the python script below to achieve this. You will need to fill in the feature service id, the layer name, and the field name you want to change the displayField to.
from arcgis.gis import GIS
## connect to AGOL
agol = GIS("home")
## the item id for the feature service to update
item_id = "FEATURE_SERVICE_ID"
## access the feature service
item = agol.content.get(item_id)
## the name of the layer within the feature service
lyr_name = "Layer_Name"
## the field name you want to use as the display field
field_name = "Field_Name"
## access the layer
lyr = [lyr for lyr in item.layers if lyr.properties.name == lyr_name][0]
## use this dictionary to update
update_dict = {
"displayField" : field_name
}
## update the layer definition
print(lyr.manager.update_definition(update_dict))
This is being driven by the display service set when publishing the feature service. You can overwrite the service or go through the admin REST api and do update definition .
The service was published from Survey123. Do you know if there is a setting in Survey123 to change this? I can't see anything obvious.
Thanks
Hi @Lee_Butler
You can use the python script below to achieve this. You will need to fill in the feature service id, the layer name, and the field name you want to change the displayField to.
from arcgis.gis import GIS
## connect to AGOL
agol = GIS("home")
## the item id for the feature service to update
item_id = "FEATURE_SERVICE_ID"
## access the feature service
item = agol.content.get(item_id)
## the name of the layer within the feature service
lyr_name = "Layer_Name"
## the field name you want to use as the display field
field_name = "Field_Name"
## access the layer
lyr = [lyr for lyr in item.layers if lyr.properties.name == lyr_name][0]
## use this dictionary to update
update_dict = {
"displayField" : field_name
}
## update the layer definition
print(lyr.manager.update_definition(update_dict))
Hi, is there a way to do this without using python? Is there a way to change the field display right in the new map viewer? Thank you
You can manually change the layer's "displayField" setting in REST services using the Update Definition operation. It does not appear that you can customize this setting for each Web Map, since they just reference the layer's definition. If you needed a different Display Field for different Web Maps, you would need to create view layers for each.
Hi @Clubdebambos,
Thanks for this script. It works great. Much appreciated