FeatureService

AMD: require(["esri/rest/featureService/FeatureService"], (FeatureService) => { /* code goes here */ });
ESM: import FeatureService from "@arcgis/core/rest/featureService/FeatureService.js";
Class: esri/rest/featureService/FeatureService
Since: ArcGIS Maps SDK for JavaScript 4.28

This class contains metadata about the feature service. The class can be constructed via a url to a feature service or from the class utils using the createFeatureServices() method.

Constructors

FeatureService

Constructor
new FeatureService(properties)
Parameter
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Examples
// Create a FeatureService from a url
const featureService = new FeatureService({
 url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer"
});

 
// Create a FeatureService using createFeatureServices()
const layer1 = new FeatureLayer({url: `https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/FeatureServer/12`});
const layer2 = new FeatureLayer({url: `https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/FeatureServer/13`});
const layers = [layer1, layer2];
const mapOfServices = createFeatureServices(layers);
//loading featureService from map object.
const featureService = await mapOfServices.get(`https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/FeatureServer`).featureService.load();

Property Overview

Name Type Summary Class
Capabilities

Describes the layer's supported capabilities.

FeatureService
Boolean

Indicates whether the instance has loaded.

FeatureService
Error

The Error object returned if an error occurred while loading.

FeatureService
String

Represents the status of a load operation.

FeatureService
String

The absolute URL of the REST endpoint for the feature service.

FeatureService
String

Describes the service's userTypeExtensions.

FeatureService
String

The url that points to the utility network layer, if it exists.

FeatureService
String

The url to the version management service, if the data is versioned.

FeatureService

Property Details

capabilities

Property
capabilities Capabilities

Describes the layer's supported capabilities.

loaded

Property
loaded Booleanreadonly

Indicates whether the instance has loaded. When true, the properties of the object can be accessed. A WebMap is considered loaded when its layers and basemap are created, but not yet loaded.

Default Value:false

loadError

Property
loadError Errorreadonly

The Error object returned if an error occurred while loading.

Default Value:null

loadStatus

Property
loadStatus Stringreadonly

Represents the status of a load operation.

Value Description
not-loaded The object's resources have not loaded.
loading The object's resources are currently loading.
loaded The object's resources have loaded without errors.
failed The object's resources failed to load. See loadError for more details.

Possible Values:"not-loaded"|"loading"|"failed"|"loaded"

Default Value:not-loaded

url

Property
url String

The absolute URL of the REST endpoint for the feature service. The URL may either point to a resource on ArcGIS Enterprise or ArcGIS Online.

userTypeExtensions

Property
userTypeExtensions String

Describes the service's userTypeExtensions.

utilityNetworkUrl

Property
utilityNetworkUrl Stringreadonly

The url that points to the utility network layer, if it exists.

versionManagementServiceUrl

Property
versionManagementServiceUrl Stringreadonly

The url to the version management service, if the data is versioned.

Method Overview

Name Return Type Summary Class
Promise<ServiceEditsResult[]>

Applies edits to features in the feature service layers.

FeatureService
Promise

Triggers the loading of the feature service instance.

FeatureService

Method Details

applyEdits

Method
applyEdits(edits, options){Promise<ServiceEditsResult[]>}

Applies edits to features in the feature service layers. New features can be created and existing features can be updated or deleted. Feature geometries and/or attributes may be modified. Only applicable to layers in a feature service.

When calling the applyEdits method on a service that does not have vertical coordinate system information, the z-values of the geometries in the edits object will automatically be converted to match the spatial reference of the layer. Example: The service has a horizontal spatial reference with feet units, and applyEdits() is called with z-values based on meter units, then the method will automatically convert the z values from meter to feet units. applyEdits() will pass in a sessionId during an active edit session.

Parameters
Specification
edits Object[]

Object containing features and attachments to be added, updated or deleted.

Specification
id Number

Specifies the layer id of the layer that needs to be edited.

identifierFields Object
Specification
globalIdField String
optional

Specifies the globalIdField of the layer being editied.

objectIdField String

Specifies the objectIdField of the layer being edited.

optional

An array or a collection of features to be added. Values of non nullable fields must be provided when adding new features. Date fields must have numeric values representing universal time.

updateFeatures Graphic[]|Collection<Graphic>
optional

An array or a collection of features to be updated. Each feature must have valid objectId. Values of non nullable fields must be provided when updating features. Date fields must have numeric values representing universal time.

optional

An array or a collection of features, or an array of objects with objectId or globalId of each feature to be deleted. When an array or collection of features is passed, each feature must have a valid objectId. When an array of objects is used, each object must have a valid value set for objectId or globalId property.

addAttachments AttachmentEdit[]
optional

An array of attachments to be added. Applies only when the options.globalIdUsed parameter is set to true. User must provide globalIds for all attachments to be added.

updateAttachments AttachmentEdit[]
optional

An array of attachments to be updated. Applies only when the options.globalIdUsed parameter is set to true. User must provide globalIds for all attachments to be updated.

deleteAttachments String[]
optional

An array of globalIds for attachments to be deleted. Applies only when the options.globalIdUsed parameter is set to true.

options Object
optional

Additional edit options to specify when editing features or attachments.

Specification
gdbVersion String
optional

The geodatabase version to apply the edits. This parameter applies only if the capabilities.data.isVersioned property of the layer is true.

globalIdUsed Boolean
optional

Indicates whether the edits can be applied using globalIds of features or attachments. This parameter applies only if the layer's capabilities.editing.supportsGlobalId property is true. When false, globalIds submitted with the features are ignored and the service assigns new globalIds to the new features. When true, the globalIds must be submitted with the new features. When updating existing features, if the globalIdUsed is false, the objectIds of the features to be updated must be provided. If the globalIdUsed is true, globalIds of features to be updated must be provided. When deleting existing features, set this property to false as deletes operation only accepts objectIds at the current version of the API.

When adding, updating or deleting attachments, globalIdUsed parameter must be set to true and the attachment globalId must be set. For new attachments, the user must provide globalIds. In order for an attachment to be updated or deleted, clients must include its globalId. Attachments are not supported in an edit payload when globalIdUsed is false.

honorSequenceOfEdits Boolean
optional

Added at 10.5 and works with ArcGIS Server services only. This parameter specifies whether to apply edits in the order they are submitted in the JSON. If true, edits will apply in the submitted order. If false, which is the default, edits will apply in ascending layer-ID order. All the edits for the layer with the lowest ID will apply first.

usePreviousEditMoment Boolean
optional

This option was added at 10.6. This is set by a client during long transaction editing on a branch version. This parameter is used to apply the edits with the same edit moment as the previous set of edits. This allows an editor to apply a single block of edits partially, complete another task, and then complete the block of edits. When set to true, the edits are applied with the same edit moment as the previous sets of edits. When set to false the edits are applied with a new edit moment. By default, this parameter is set to false.

returnServiceEditsInSourceSR Boolean
optional

When this parameter is set to true, edits returned by the return service edits option will be in the source spatial reference of the layer they belong to.

Returns
Type Description
Promise<ServiceEditsResult[]>
Example
featureService.applyEdits(
  [
    {
      id: 1,  // layer id of the layer in the feature service
      identifierFields: { globalIdField: "GLOBALID", objectIdField: "OBJECTID" },
      addFeatures: [
        new Graphic({
                geometry: new Point({
                  x: -13293155.7588,
                  y: 4038940.6944999993,
                  z: 0,
                  spatialReference: {
                    wkid: 102100,
                    latestWkid: 3857,
                    xyTolerance: 0.001,
                    zTolerance: 0.001,
                    mTolerance: 0.001,
                    falseX: -20037700,
                    falseY: -30241100,
                    xyUnits: 10000,
                    falseZ: -100000,
                    zUnits: 10000,
                    falseM: -100000,
                    mUnits: 10000
                  }
                }),
                attributes: {
                  objectid: 3,
                  name: "test",
                  globalid: "{8E17A611-B139-46E4-A645-AC50A1DD2CCE}",
                  created_user: "unadmin",
                  created_date: 1694024410000,
                  last_edited_user: "unadmin",
                  last_edited_date: 1694024410000
                }
              }))
      ]
    }
  ],
  {
    gdbVersion: "user.versionName",
    globalIdUsed: false,
    honorSequenceOfEdits: false,
    usePreviousEditMoment: false,
    returnServiceEditsInSourceSR: false
  }
);

load

Method
load(){Promise}

Triggers the loading of the feature service instance.

Fully loads the Feature Service definition.

Returns
Type Description
Promise Resolves when the Feature Service is loaded.

Type Definitions

Capabilities

Type Definition
Capabilities Object

Describes the layer's supported capabilities.

Properties
data Object

Describes characteristics of the data in the service.

Specification
isVersioned Boolean

Indicates if the feature service is versioned.

editing Object

Describes editing capabilities that can be performed on the features in the layer via applyEdits().

Specification
supportsGlobalId Boolean

Indicates if the globalId values provided by the client are used in applyEdits.

supportsReturnServiceEditsInSourceSpatialReference Boolean

Indicates that the service supports returning edits in the source spatial reference of the layer they belong to.

supportsAsyncApplyEdits Boolean

Indicates if the service supports async apply edits.

supportsSplit Boolean

Indicates whether the service supports splitting features.

operations Object

Describes operations that can be performed on features in the layer.

Specification
supportsAdd Boolean

Indicates if new features can be added to the service.

supportsChangeTracking Boolean

Indicates whether the service supports change tracking for features.

supportsDelete Boolean

Indicates if features can be deleted from the service.

supportsEditing Boolean

Indicates if features in the service can be edited. Use supportsAdd, supportsUpdate and supportsDelete to determine which editing operations are supported.

supportsQuery Boolean

Indicates if features in the service can be queried.

supportsQueryDataElements Boolean

Indicates whether the service supports querying data elements.

supportsQueryDomains Boolean

Indicates whether the service supports querying domains.

supportsQueryContingentValues Boolean

Indicates whether the service supports querying contingent values.

supportsSync Boolean

Indicates whether the service supports synchronization.

supportsUpdate Boolean

Indicates whether the service supports updating features.

query Object

Describes query operations that can be performed on the Feature Service.

Specification
maxRecordCount Number

The maximum number of records that will be returned for a given query.

maxRecordCountFactor Number

This property is used to limit the number of records returned based on a factor of the query.maxRecordCount.

sync Object

Describes the synchronization capabilities of a service.

Properties
supportsAsync Boolean

Indicates whether the service supports asynchronous synchronization.

supportedSyncDataOptions Boolean

Indicates the supported sync data options for the service

Specification
annotations Boolean

Indicates whether annotations should be included in the sync data.

dimensions Boolean

Indicates whether dimensions should be included in the sync data.

contingentValues Boolean

Indicates whether contingent values should be included in the sync data.

attributeRules Boolean

Indicates whether attribute rules should be included in the sync data.

utilityNetworkSystem Boolean

Indicates whether the utility network system should be included in the sync data.

annotationFullModel Boolean

Indicates whether the full annotation model should be included in the sync data.

include3DObjects Boolean

Indicates whether 3D objects should be included in the sync data.

utilityNetworkMissingLayers Boolean

Indicates whether missing utility network layers should be included in the sync data.

preserveTrueCurves Boolean

Indicates whether true curves should be preserved in the sync data.

ServiceEditsResult

Type Definition
ServiceEditsResult Object

Results returned from the applyEdits method. It contains features that were added, deleted or updated in different feature layers. It also contains the edit moment.

Properties
id Number

The layerId of the feature layer where features were edited.

addFeatureResults Object[]

Results returned from an add operation.

updateFeatureResults Object[]

Results returned from an update operation.

deleteFeatureResults Object[]

Results returned from a delete operation.

addAttachmentResults Object[]

Results returned from an add attachments operation.

updateAttachmentResults Object[]

Results returned from an update attachments operation.

deleteAttachmentResults Object[]

Results returned from a delete attachments operation.

editedFeatures Object[]
optional

Object containing all edited features belonging to the specified layer.

editMoment Number
optional

Returns the editMoment of an edit.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.