After updating a freature layer via S123 connect, I cannot add the new fields to a view layer that I have been using with this project. The fields just don't show up in the "Update View" tool in AGOL. When I create a new View Layer from the Hosted Feature Layer, the new fields are available for use. Any way to fix the original view layer? It's a pain to recreate the view layer and remap all of the services that use it.
Not sure if relavent but one of the changes I made when adding new fields to the feature layer was enabling attachments on one of the related tables.
Will likely reach out to support on this and am still in the testing phase of this project but it would be great to know what to do if this ever comes up again in the future as this project will have a long lifespan. Any advice would be appreciated.
We see this a lot. Best practice is to add the new field from the layer's page in AGOL, which, somehow, makes the field available to your views.
When you add the field elsewhere, such as Pro or S123, and overwrite the layer, any dependent views will not see the new fields.
You can edit the layer JSON to include the new fields, using something like the AGO Assistant or the Python API.
Hi Josh,
I added new fields in AGOL and in my non editable view I was able to add the fields through update view. However in my editable views they failed to appear. I am looking for a solutions and came across your reply. Where in the AGOL assistent JSON file do I add the new field to the editable view? In the popupInfo?
I hope to hear from you!
- Zoë
Hi Zoë, Did you ever find out how to do this? I am running into the same issue.
I ended up creating a new view which had the new fields. But not even a week later I figured that I needed yet another field so I decided to just give up.
Sorry for the delayed response, and thanks @IanGallo for getting this back on my radar.
It would appear that the AGO Assistant does not let you modify the view in this way, and I was confusing it with using the Python API. I use both frequently enough that I sometimes forget which functionality is in which place.
If you're comfortable using Python, check out the update_definition method of the FeatureLayerManager class.
source_fl = gis.content.get('itemid').layers[0] # or whatever layer index
source_field_props = source_fl.manager.properties['fields']
# You can modify the feature layer properties if you want
dest_fl = gis.content.get('itemid').layers[0] # or whatever layer index
dest_props = dest_fl.manager.properties
dest_props['fields'] = source_field_props
dest_fl.manager.update_definition(dest_props)
Hi Josh,
Thank you for providing us the code to update the layers! However I agree with @IanGallo that this isn't very user friendly. You stated earlier that when adding the fields through AGOL you will be able to see them in the updated views, this isn't correct. I added new fields in the Layers page and they never appeared. Weirdly enough these fields are visible in the filter you can set in the update view window. So it does know the new field because u can use them for a filter (which you obviously can't use), but when in comes to adding new fields to the View it doesn't understand. Seems rather strange to me.
Maybe it's just a bug?
- Zoë
Oh, I forgot to mention that when you add a new field to the parent layer, at least in older versions of AGOL and Portal, it is by default excluded from the view layers.
If you go to the Update View page, I suspect you can turn the new fields on.
Just to confirm, on the Update View page, how many fields does it show being available?
Unfortunately not all fields. There should be 34 available:
In the Feature layer I have 36 fields in de Data tab and in the view there are 35.
Maybe its because I uploaded the FL in an earlier version of AGOL through Pro.
Hm. Could be. Overwriting a layer with published views and simultaneously modifying the schema is just asking for trouble. I've broken a lot of layers that way!