HOW TO

Replace layer view source for hosted feature layers in ArcGIS Online

Last Published: September 8, 2022

Summary

In some instances, hosted feature layer views that become corrupted cannot be fixed or overwritten, which may affect other critical web maps or web apps. To reconfigure these web maps or web apps with a new hosted feature layer view created from a republished hosted feature layer can be time-consuming.

However, it is possible to direct existing layer views to a republished hosted feature layer view while maintaining the references to the existing layer views in the client's apps and maps.

The workflow in this article describes how to achieve this via the layer view's REST endpoint.

Procedure

Publish the new hosted feature layer to replace the corrupted hosted feature layer with the same spatial reference as the existing layer view.

  1. In ArcGIS Online, open the desired layer view.
  2. In the Overview page, scroll down to locate the URL section.
  3. Click View The View button.png to open the layer's REST endpoint window.
  4. In the ArcGIS REST Services Directory window, click Admin.
Image of ArcGIS REST Services Directory Admin link
  1. In the ArcGIS REST Services Directory window, scroll down and click Delete From Definition.
  2. Under ArcGIS REST Services Directory, replace the code in the Delete From Service Definition text box with the following code:
{

"layers": [{"id": 0 }]

}
The code replacement
  1. Click Delete From Service Definition to save and return to the previous page.
  2. In the ArcGIS REST Services Directory window, scroll down and click Add To Definition.
  3. Under ArcGIS REST Services Directory, replace the code in the Add To Service Definition text box with the following code:
{
 "layers": [
  {
   "adminLayerInfo": {
    "geometryField": {"name": "Shape"}, 
    "xssTrustedFields": "",
    "viewLayerDefinition": { 
      "sourceServiceName": "<name_of_service>", 
      "sourceLayerID":0,
      "sourceLayerFields":"*"
   } }, 
   "id": 0, 
   "name": "<name_of_layer>", 
   "type": "Feature Layer",
   "serviceItemId":"<item_ID>",
   "isView": true,
   "isUpdatableView": true,
   "sourceSchemaChangesAllowed": true, 
   "displayField": "", 
   "description": "", 
   "copyrightText": "", 
   "defaultVisibility": true
}]
}
Note:
For hosted table views, modify the following parameters in the JSON:
• geometryField: null
• type: "Table"
Note:
The new hosted feature layer must have the same spatial reference as the existing layer view. This process may fail if a different spatial reference is used. For more information, refer to ArcGIS Pro: An overview of spatial references.
The code replacement
  1. Click Add To Service Definition to save.

Article ID:000026235

Software:
  • ArcGIS Online
  • ArcGIS REST API

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic