View on GitHub Sample viewer app

Update feature attributes in an online feature service.

Image of update attributes feature service

Use case

Online feature services can be updated with new data. This is useful for updating existing data in real time while working in the field.

How to use the sample

To change the feature’s damage property, click on the feature to select it, and update the damage type using the drop down.

How it works

  1. Create and load a ServiceGeodatabase with a feature service URL.
  2. Get the ServiceFeatureTable from the service geodatabase.
  3. Create a FeatureLayer from the service feature table.
  4. Select features from the FeatureLayer.
  5. To update the feature’s attribute, first load it, then use .getAttributes().put(keyValuePair) to modify the desired attribute.
  6. Update the feature table with .updateFeatureAsync(feature).
  7. Apply edits to the ServiceGeodatabase by calling applyEditsAsync, which will update the feature on the online service.

Relevant API

  • ArcGISFeature
  • FeatureLayer
  • ServiceFeatureTable
  • ServiceGeodatabase

Tags

amend, attribute, details, edit, editing, information, update, value

Sample Code

module-info.java module-info.java UpdateAttributesSample.java
/*
* Copyright 2022 Esri.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module com.esri.samples.update_attributes {
// require ArcGIS Maps SDK for Java module
requires com.esri.arcgisruntime;
// handle SLF4J http://www.slf4j.org/codes.html#StaticLoggerBinder
requires org.slf4j.nop;
// require JavaFX modules that the application uses
requires javafx.graphics;
requires javafx.controls;
exports com.esri.samples.update_attributes;
}