Change default field displayed in Map Viewer edit tool

1049
4
Jump to solution
02-27-2023 02:07 AM
LeeButler1
New Contributor II

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

 

 

Tags (3)
1 Solution

Accepted Solutions
Clubdebambos
Occasional Contributor III

Hi @LeeButler1 

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))

 

 

~ Mapping my way to retirement

View solution in original post

4 Replies
RussRoberts
Esri Notable Contributor

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 .

LeeButler1
New Contributor II

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

0 Kudos
Clubdebambos
Occasional Contributor III

Hi @LeeButler1 

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))

 

 

~ Mapping my way to retirement
LeeButler1
New Contributor II

Hi @Clubdebambos,

Thanks for this script.  It works great. Much appreciated