editingEnabled Property is always return as True for feature layers

659
3
Jump to solution
08-03-2021 05:31 AM
MayoTestUser
New Contributor II

 

Hi, I have hosted two feature layers in ArcGIS Online 10.8 and consumed it as portal items in my webmap application using ESRI Javascript API 4.19. I have enabled editing for one feature layer and not enabled the editing for another feature layer since it is read-only.

I shared these two layers to an user account (named 'test_user') which has the role of 'users'. when I logged into the webmap application using 'test_user' account, I am able to retrieve these two layers from portal items.

But when looking at 'editingEnabled' Property of both layers, it returns as True. But actually for one feature layer, it should return as False. Even if I untick the 'Editing Enabled' option for hosted feature layers in ArcGIS Online, it's still return as True in the application.

 

view.map.layers.forEach(function (layer, index) {
      console.log(layer.editingEnabled);
});

 

 Suggest me a method to get the edit access of feature layer in Javascript API. Many thanks in advance.

0 Kudos
1 Solution

Accepted Solutions
BjornSvensson
Esri Regular Contributor

This is a bug in the ArcGIS API for JavaScript - that editingEnabled is always true.

However, you can take advantage of the sourceJSON property, which includes all the REST metadata for the service.

Specifically, layer.sourceJSON.capabilities will show the available capabilities, including the editing settings.

For example, if editing is enabled on a hosted feature layer (depending on what other editing options have been set):
Create,Delete,Query,Update,Editing,Sync

And if the editing is not enabled, something like:
Query,Sync



View solution in original post

0 Kudos
3 Replies
LindaKoch1
New Contributor

I too, have a similar issue.  I have several hosted feature services set to "not editable" within the settings tab on AGOL.  When these are pulled into ArcGIS Pro, they become editable.  The setting in not inherited from the source.  How do I restrict users from editing the portal layers.  This is a significant issue for us.

0 Kudos
BjornSvensson
Esri Regular Contributor

This is a bug in the ArcGIS API for JavaScript - that editingEnabled is always true.

However, you can take advantage of the sourceJSON property, which includes all the REST metadata for the service.

Specifically, layer.sourceJSON.capabilities will show the available capabilities, including the editing settings.

For example, if editing is enabled on a hosted feature layer (depending on what other editing options have been set):
Create,Delete,Query,Update,Editing,Sync

And if the editing is not enabled, something like:
Query,Sync



View solution in original post

0 Kudos
MayoTestUser
New Contributor II

Many Thanks Bjorn, it works well !

0 Kudos