Select to view content in your preferred language

Change default field displayed in Map Viewer edit tool

1950
6
Jump to solution
02-27-2023 02:07 AM
Labels (1)
Lee_Butler
Occasional Contributor

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
Frequent Contributor

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

 

 

~ learn.finaldraftmapping.com

View solution in original post

6 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 .

Lee_Butler
Occasional Contributor

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
Frequent Contributor

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

 

 

~ learn.finaldraftmapping.com
MatthewCady
New Contributor

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

0 Kudos
Kuyler_JonesCivil
Occasional Contributor

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.

0 Kudos
Lee_Butler
Occasional Contributor

Hi @Clubdebambos,

Thanks for this script.  It works great. Much appreciated