I have a situation that seems counterintuitive, but hear me out. I created a point hosted feature layer and a web map. Editing was and is disabled for that layer. I've made public web maps and apps from this data.
Now the customer wants a second web map/app for some of their staff to edit the points (add, delete, move, update attributes).
At first, I was unhappy about this request because it meant that the hosted feature layer currently in a public web map would need to have its edit capability turned on, which I don't want to do in a public web map. This would necessitate creating a new "public read-only" View of that hosted feature layer and re-source the web maps and apps to that public View. That would be A LOT of work to reconfigure the apps to point to that view.
I had an idea today. Is it possible to keep the original hosted feature layer in its current "read-only" state but create a View from that, make the View editable, and then make the staff editor web map use that View?
I went through all the steps to test this out, and everything pointed to "Yes," this should work. I created the View, then went to the View settings and turned on editing (even though the originating hosted feature layer is not enabled for editing).
However, now, when I go into a web map with that new, editable layer View and try to add a new feature, I get the following error: "Edits could not be saved: Cannot perform operation. Invalid operation parameters."
When I look at the "applyedits" response in the browser network traffic console after I get that error message, I see a more detailed message as follows, "An item with the same key has already been added".
I can move existing points and update their attributes, but I can't add new points.
Is this because I have an editable layer View based on a non-editable hosted feature layer, or some other reason?
Solved! Go to Solution.
This Esri documentation has some really good information on what settings are inherited in the view from the hosted feature layer that can and cannot be changed on the view.
Per the documentation, edit settings can be configured independently on the views from the hosted feature layers they are created from. Meaning that you should be able to allow editing on the view, with it still disabled on the hosted feature layer. (Note that some additional edit settings, such as editor tracking, must be made at the hosted feature layer level. But the enable/disable editing setting itself can be changed independently on the view).
This is something that I just tested with my own hosted feature layer/view in AGOL and it works fine for me. Editing is disabled in the hosted feature layer, but enabled on the view and I can add new data as well as edit existing data.
Your "applyedits" response in the network traffic indicates a different problem. It appears that it is trying to add a record with the same key, which is not possible to do. For example, if ObjectID is your key field and you have a record with an ObjectID of 1. And then you try to add a new record with an ObjectID of 1, it will fail because a key with that value already exists. I've never really heard of that being a problem in AGOL though.
If it's possible, it might be worth trying to enable editing on your hosted feature layer and see if you are able to add new records to it, or if you receive the same error. If you don't receive any errors, it might be worth trying to delete and re-create the view again. And if you do receive errors in the feature layer itself, then I think you have a different problem that needs to be resolved.
This Esri documentation has some really good information on what settings are inherited in the view from the hosted feature layer that can and cannot be changed on the view.
Per the documentation, edit settings can be configured independently on the views from the hosted feature layers they are created from. Meaning that you should be able to allow editing on the view, with it still disabled on the hosted feature layer. (Note that some additional edit settings, such as editor tracking, must be made at the hosted feature layer level. But the enable/disable editing setting itself can be changed independently on the view).
This is something that I just tested with my own hosted feature layer/view in AGOL and it works fine for me. Editing is disabled in the hosted feature layer, but enabled on the view and I can add new data as well as edit existing data.
Your "applyedits" response in the network traffic indicates a different problem. It appears that it is trying to add a record with the same key, which is not possible to do. For example, if ObjectID is your key field and you have a record with an ObjectID of 1. And then you try to add a new record with an ObjectID of 1, it will fail because a key with that value already exists. I've never really heard of that being a problem in AGOL though.
If it's possible, it might be worth trying to enable editing on your hosted feature layer and see if you are able to add new records to it, or if you receive the same error. If you don't receive any errors, it might be worth trying to delete and re-create the view again. And if you do receive errors in the feature layer itself, then I think you have a different problem that needs to be resolved.
Hi Ryan. Thanks for the thoughtful reply.
After posting this thread, I did exactly as you suggested and turned editing on for the originating hosted feature layer, and sure enough, it delivered the same error. That supports your other statements about how views work vis-a-vis their originating hosted feature layer. I also exported the layer to an FGDB and then republished it as a test layer, and that layer edits just fine as an editable view where the host layer is edit-disabled.
I guess the answer to this issue is; somehow my originating layer got corrupted. I'll mark your comment as the solution. Thanks again.