Hosted Feature Layer - delete one of the layers within it?

9685
9
01-22-2016 09:14 AM
by Anonymous User
Not applicable

Hello all,

I have a hosted feature layer that has 16 layers within it. I want to delete the first layer but I would like to avoid having to delete the whole service and republishing from ArcMap because this layer is live and there are edits being made on it. I would have to download the data in fgb and then repath that data in my ArcMap mxd and then republish. Then I would probably have to recreate the web map and the web app because I have had problems in the past of my existing web maps and apps reading any changes to my feature layers.

What about this blog and PDF referenced in blog? https://blogs.esri.com/esri/arcgis/2014/10/19/updating-hosted-feature-services-in-arcgis-online/

PDF referenced in blog: https://blogs.esri.com/esri/arcgis/files/2014/10/How-to-Update-Hosted-Feature-Service-Schemas1.pdf

In the service URL of the layer I want to delete I see, "Delete from Definition". But does that just delete a few fields in that layer and not the layer itself?

delete from definition.JPG

Does anyone have any ideas?

Thank you.

0 Kudos
9 Replies
New_RiverLand_Trust
New Contributor

Is there a solution for this? Still do not see a way to delete a single layer within a Feature Service on ArcMap online.

JoeCatanzarita1
Occasional Contributor II

Hello Andrea,

I hope this finds you well!

Unfortunately, there isn't a way to get rid of one or more layers within a Hosted Feature Service without deleting and republishing the service OR using ArcGIS Online Assistant (ArcGIS Online Assistant). If you wish to use ArcGIS Online Assistant, I would recommend making a copy of the service before you make any changes. You should proceed with caution using this workflow, as if its not done correctly, problems may occur with the service.

Below is the workflow for using ArcGIS Online Assistant:

  1. In ArcGIS Online, go to the Item Details of your Hosted Feature Service. Select the particular layer you'd like to remove and it should take you to a URL similar to this: https://services.arcgis.com/Wl7Y1m92PbjtJs5n/arcgis/rest/services/test_remove_layer/FeatureServer/0 
    • The /FeatureServer/0 is important, as you'll need to know this specific number later. 
  2. Once you know the specific number of the layer within your Hosted Feature Service, we can move over to ArcGIS Online Assistant. 
  3. Sign in with your ArcGIS Online credentials.
  4. At the top, select "I want to..." and then select "View an Item's JSON".
  5. On the left-hand side, navigate to your Hosted Feature Service that needs alteration and select it. You'll notice the service JSON populate on the right-hand side. 
  6. Scroll down to the start of the "Data" section of the JSON. Start to look for "id" : 0, "id" : 1, "id": 2, etc. Look for the id number that corresponds with the number in the URL (from step 1), this is the id we're going to remove. 
  7. At the top of the Data section, select the "pencil" icon to start editing. Start with the open bracket above "id" : # and highlight all the way down to the close bracket of the section. Proceed to delete this section and make sure the JSON brackets are aligned correctly before saving the section. 
  8. After you've deleted the section, this specific layer will be deleted and you should be good to go.

I know it's a long one, but if you wish to take on this specific workflow, I've recorded myself performing the workflow. You can access the video here: https://www.screencast.com/t/QlDosHbdNJ

Cheers,

Joe

PersefoniKapotas
New Contributor III

Hope this isn't a silly question, but how am I supposed to make a copy of the service?  I can save as a new map, but how do I create a copy of the service?

AlainChouinard
New Contributor III

Hi Joe, thanks for this solution, it seems to work well and not too complex.

But I have a problem : some of my hosted feature layers have this "Data" section, but for others this section doesn't exist  at all or is empty ! And obviously the hosted feature service from which I want to delete a layer doesn't have this "Data" section 😞

How can I access this "Data" section ?

Regards

Alain

JenLangevin
New Contributor III

@JoeCatanzarita1 and @AlainChouinard Did you find a way to see the data section? I am having the same problem. 

0 Kudos
AlainChouinard
New Contributor III

Hi Jen,

No I didn't... Finaly I renamed this layer as xxx_Old and is still in the Feature Layer.

Alain

0 Kudos
MatthewMaloney
New Contributor

Hi Joe, 

Thanks for this! I just have one question. After removing the layer from the JSON, should the subsequent layers be renumbered? I.e. if I remove "id": 3, should "id": 4 become 3?

Thanks in advance

Matt

0 Kudos
PeterGoedbloed1
New Contributor III

Recently, the URL scheme of AGOL has changed to: https:/<your org>.maps.arcgis.com/home/item.html?id=<itemid> &sublayer=<your sublayer> &view=service (which is great because they now include de service id).

but the workflow still works. However, don't forget to delete the "," from the layer above the deleted layer if that is the last one. 

0 Kudos
mikAMD
by
Occasional Contributor II

You are trying to delete a layer inside a feature service, correct?

I have done this multiple times with the deleteFromDefinition endpoint of the REST API.

You can write a json similar to this on the html page if you are not familiar with API calls.

{
     "layers": [{"id": 7}] // layer id
}
 
mikAMD_0-1668198316256.png