Answer
No, an overwritten feature layer cannot be recovered in ArcGIS Online. However, the changes made to a hosted feature layer can be extracted in JSON format via the ArcGIS REST Services Directory if the layer settings are configured to allow change tracking. The change tracking record can be obtained by using the Extract Changes operation in the ArcGIS REST Services Directory. The Extract Changes operation can return the added, updated, and deleted data. Querying for updated data returns the updated data for the features only, not the previous version. The pre-edited data cannot be recovered via this operation. However, deleted data can be recovered and re-added to the hosted feature layer.
The steps below describe the workflow to recover and re-add deleted data to the hosted feature layer via the ArcGIS REST Services Directory.
Note:
The deleted features' objectIDs are not retained when the features are re-added. The re-added features are assigned new objectIDs consecutively from the last value.
- In ArcGIS Online, open the hosted feature layer’s item details page.
- Copy the layerServerGens syntax from the JSON file.
- On the Overview tab, next to URL, click View to open the ArcGIS REST Services Directory.
- In the ArcGIS REST Services Directory, click JSON to open the JSON file.
- Press Ctrl + F to open the search box and type layerServerGens.
- Highlight the layerServerGens syntax and press Ctrl + C to copy it.
- Open the Extract Changes page in the ArcGIS REST Services Directory.
- In the browser, click the back arrow to return to the feature service page.
- At the bottom of the page, in the Supported Operations list, click Extract Changes.
- Specify the parameters in the Extract Changes page in the ArcGIS REST Services Directory.
- For Layers, specify the layer ID. In this example, 0 is specified.
- For Geometry Type, click the drop-down arrow and select the geometry type. In this example, Point is selected.
- For Return Deletes, ensure the True radio button is selected.
- For Return Deleted Features, click the True radio button. Leaving it set to False returns the globalID only.
- For Layer Server Gens, paste the layerServerGens syntax copied in Step 2.
- Leave the rest of the parameters as default.
- Click Extract Changes. This refreshes the page.
- Download the JSON file and copy the deleted feature syntax.
- On the Extract Changes page, click the statusURL link. The page redirects to the Extract Changes Status page.
- Click the Result URL link to download the JSON file.
- Open the JSON file and search for deletes.
- Highlight the deleted feature syntax and press Ctrl + C to copy it.
- Re-add the deleted features to the feature service using the Add Features operation.
- On the ArcGIS REST Services Directory feature service page, under Layers, click the layer name to redirect to the layer’s page.
- At the bottom of the page, in the Supported Operations list, click Add Features.
- On the Add Features page, for Features, paste the copied syntax from Step 5 into the text box.
- For Rollback on Failure, ensure the True radio button is selected.
- For Format, click the drop-down arrow and select JSON.
- Click Add Features.
The image below shows the JSON response syntax when the deleted features are successfully added to the feature service.