🔄 Update or Publish Hosted Feature Layers from an APRX
This script automates the process of updating or publishing web feature layers to ArcGIS Online (AGOL) or Enterprise Portal directly from an ArcGIS Pro project (.aprx).
It supports flexible publishing options while preserving key metadata and ensuring that published content stays consistent with the source APRX.
🔧 Key Capabilities
Connects to AGOL or Portal and loads a specific APRX and map by name.
Supports two publishing modes:
Single Service: Publishes all non-basemap layers as a combined web feature layer.
Individual Layers:
PublishGroupLayer: Publishes each top-level group layer as a unit.
PublishSubLayers: Publishes each sublayer independently.
Reuses metadata from existing hosted feature layers, including: Title, description, tags, thumbnail, credits, license info, and sharing settings.
Retains feature service properties like editor tracking and capabilities.
Applies symbology, pop-ups, and labeling directly from the APRX.
Generates .sddraft and .sd files, stages them, publishes the service, and cleans up temporary files.
⚠️ Behavior Notes
If no matching hosted feature layer is found, a new one is created in the specified portal folder.
Matching is based on exact name matching between the APRX layer and the AGOL/Portal item title.
Any manual changes made via the AGOL/Portal Visualization tab will be overwritten by the APRX.
Attachments are not supported — layers with attachments are skipped.
Raster layers are not supported.
🔁 Change Detection (New)
A local JSON cache tracks key characteristics of each layer: Field schema, Record count and max OBJECTID, Last edited date, Symbology, labeling, and pop-ups
Each element is hashed and compared to previous runs.
If no changes are detected, the layer is skipped to save processing time.
On the first run, all layers are published and the cache is initialized.
Note: Change detection only applies when publishing individual layers. It is not used when publishing the entire map as a single feature layer.
✅ Example Use Case
Use this transformer to regularly push updates from a QA/staging .aprx to production AGOL layers, while preserving styling and avoiding redundant republishing.
Would you like to know more? Click here to find out more details!