As the owner of a hosted feature layer view, you can replace the view's source hosted feature layer. This is useful if you have the same source data, but the attribute values have changed.
Using a new hosted feature layer for a view's source allows you to do the following:
- Test the new source layer to ensure it is ready before you swap the view's source.
- Reduce the amount of time it takes to replace the layer's content. For example, overwriting a layer or appending data takes longer to complete than swapping the view's source layer.
- Increase the likelihood that the data updates successfully and the view continues to meet your needs. Most of the requirements listed in the next section are checked as part of the source swapping process, which means you are less likely to make changes in the data that render the view unusable.
- You can keep the original source layer as an archive of the data's previous state.
- If you determine that the new source layer is not appropriate or has negatively affected the view, you can swap the view's source to use the previous source layer.
Several conditions must be met to use a hosted feature layer as the new source for an existing hosted feature layer view. Those are listed in the next section.
Requirements
The following conditions must be met to swap a view's source and ensure that there is no disruption to the apps using the view:
- You must own the new source hosted feature layer and the hosted feature layer view.
- The new source layer must use the same spatial reference as the original source layer.
- The sync setting on the new source layer and the view must be the same. If the view layer has sync enabled, the new source layer must have sync enabled. If the view layer does not have sync enabled, the new source layer cannot have sync enabled.
- The new source layer must contain the same number of sublayers as the original source layer.
- The sublayers in the new source layer must have the same layer IDs as those in the original source layer, and the sublayers must be in the same order.
- The sublayers in the new source layer must use the same geometry types (such as points, lines, or polygons) as they did in the original source layer.
- The sublayers in the new source layer must contain the fields that are included in the view's field definition.
- The fields in the new source layer must be the same data type as the fields that were present in the original source layer.
- The view cannot currently be in use in an offline map.
- The view cannot have dependent raster or vector tile layers.
- You cannot swap the source for a joined hosted feature layer view.
Swap the view's source layer
To swap the source hosted feature layer of a hosted feature layer view, complete the following steps:
- Open the item page of the hosted feature layer view.
- Click the Settings tab.
- Scroll down to the Feature Layer (hosted, view) section and click Update View.
- Click Swap source.
A list of layer requirements appears.
- Read the requirements that the new source layer must meet.
- Click Browse for a layer and find the replacement hosted feature layer to use as the view's source layer.
You can use the search or sort the results to find the layer.
- Click the Swap source button associated with the hosted feature layer to use as the new source for the view.
If the replacement layer meets all requirements, the hosted feature layer view references the new hosted feature layer's data and a message appears indicating the swap succeeded.
- Click OK on the success message to close it.
- Click Next.
- Optionally, proceed with editing the view definition.
- Click Update when you finish all changes to the hosted feature layer view.
To revert to the original source layer, repeat the steps above and use the original source layer as the new source layer.