Data Management

What’s new with hosted feature layers: Getting to know Append, Part 2

If you read Part 1 of our 2-part blog series, you learned that you can insert new features into a hosted feature layer using Append. Append has a few more tricks up its sleeve, though.  From Part 1, you may remember the option to Update existing features, and that’s the topic of today’s blog post—taking advantage of this option to either update existing features or update and insert existing features (affectionately called an upsert in the database world).  While the Update existing features check box is small and unassuming, it opens the door for some useful workflows.

How does it work?

The Update existing features option works by matching the ObjectID or GlobalID (We want to expand that to user-driven unique IDs in a future release) from the feature layer to a field of the same type in the file that contains the updates. If there’s a match, the existing feature’s attributes are updated. If a feature in your upload file has no match based on the ID, the feature will instead be inserted into the feature layer, resulting in an upsert (matching records are updated, new records are inserted).

ObjectIDs vs. GlobalIDs

If you are doing regular updating using the Append tool, we recommend that you use GlobalIDs. ObjectIDs are unique, but as features are deleted they can also be recycled and used again for a different feature.  In large datasets that are changing, this can increase the risk of updating the wrong feature.  My general advice is ObjectIDs can work well for smaller focused updates, where you know the ObjectID’s match. For larger, more dynamic data, GlobalIDs are the way to go.

Tip:  Make sure you have Preserve GlobalIDs turned on in your geoprocessing environment settings in Pro or ArcMap if you are exporting data to use in Append’s upsert functionality.  This will preserve your GlobalIDs when you export data, making your life easier.

Append update

Append’s update functionality should be a straightforward concept to wrap your head around. You might have updates to make to existing features, and because the data in the feature layer is changing, a simple overwrite is difficult.  Or maybe you just want to avoid any downtime on your feature layer because it’s mission critical. In that case, just package up your updates, match to your GlobalID field, optionally choose to update the geometry, and use Append to apply the updates to the layer.

Diagram showing append update results

Append upsert

Append’s upsert functionality is a bit more specialized, but can save you a few extra steps when the stars align (or more accurately, your data does). When deciding between using upsert or doing a two-step insert followed by an update, it really comes down to whether the data you want to update and insert will use the same set of fields.  For instance, you may need to insert some new rows (many fields) and also update existing records for just one field (maybe to correct a miscalculated value).  In that scenario, it probably makes sense to just do it in two separate operations.  However, if the fields you want to update are the same as the fields you want to insert, you can save yourself a step and do it all at once.

For example, suppose you are maintaining a table of personal information like people and addresses, and your update contains new people, but also the same revised information (fields) about existing people (new address, etc.). In a scenario like this, you can use upsert to do it all in a single step.

Diagram showing append upsert results

Tip:  As I mentioned in Part 1, it’s never a bad idea to make a quick export of your feature service as a backup when performing large append operations. With bulk operations, it can be difficult at times to review every feature before appending, and having a backup handy can make life easier if the wrong data is appended.

Want to learn more?

If you are looking for more information regarding Append or additional information about managing data in ArcGIS Online, head over here.

About the author

Product Engineer for ArcGIS Online and technology enthusiast.


Next Article

Use Arcade geometry functions with FeatureSets to provide spatial context

Read this article