Select to view content in your preferred language

Create a hosted feature layer and show objectID by default.

731
1
08-22-2023 04:30 PM
ChrisCrowe1
Emerging Contributor

I want to create a hosted feature layer or update an existing one to show the objectID by default when viewing fields data.

I am confused because on the updateDefinition page on sample 11 there is an attribute called "visible" in the updated field;

https://developers.arcgis.com/rest/services-reference/online/update-definition-feature-layer-.htm

Here is my updateDefinition I am using (based on the sample #11 above)

 

{
  "fields": [
    {
      "name": "objectid",
      "alias": "fID 1234567890",     
      "visible": true
    }
  ]
}

 

I get a success when I test this using Insomnia (like postman) but the data does not update with a visible attribute when I test with the following url

https://server.com/server/rest/services/Hosted/vms_1089_VMSData/FeatureServer/7?f=json&token=...toke....

ChrisCrowe1_0-1692746982967.png

I have also seen reference to using the popupFields to control visibility.  Is this process documented?

 

0 Kudos
1 Reply
JoelBennett
MVP Regular Contributor

I think the problem here is that three different things are being considered as if they were the same, or at least closely related...however, they are quite distinct.

1) The visible property for a field on the Update Definition operation determines whether or not the field (and its data) is exposed to the service.  If the value is set to false, then information for that field will not be returned in a request for service information, nor will it be included in a query response.  To the end user, it will be as if the field doesn't exist at all.

2) The Field object within the SDK does not have a visible property, because it would have no meaning.  As far as a layer at runtime within the SDK is concerned, either a field exists or it doesn't.  It if exists, the information about it will be in the response sent by the server when the object requests information about the layer (e.g. as seen in the image you posted).  Otherwise, no information is provided to the client about fields that, in essence, don't exist.

3) Whether or not a field and its information is visible in the Popup when you click on a feature is determined by how the layer's PopupTemplate is setup.  Setting up a PopupTemplate is a very broad topic, but it gives you full control over what is displayed and what isn't.  For example, the fieldInfos property allows you to specify information about the fields via FieldInfo objects.  These FieldInfo objects have a visible property that would allow you to control whether the field is displayed or not.

0 Kudos