Skip to content

FeatureService

ESM: import FeatureService from "@arcgis/core/rest/featureService/FeatureService.js";
CDN: const FeatureService = await $arcgis.import("@arcgis/core/rest/featureService/FeatureService.js");
Class: @arcgis/core/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

Describes the layer's supported capabilities.

FeatureService

Describes effective capabilities of the service taking in to consideration privileges of the currently signed-in user.

effectiveCapabilities

Contains info of all layers in the Feature Service.

FeatureService

The Error object returned if an error occurred while loading.

FeatureService

Represents the status of a load operation.

FeatureService

A list of warnings which occurred while loading.

FeatureService

Indicates whether the instance has loaded.

FeatureService

Contains info of all tables in the Feature Service.

FeatureService

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

FeatureService

Describes the service's userTypeExtensions.

FeatureService

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

FeatureService

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

FeatureService

Property Details

capabilities

Property
capabilities Capabilities |null |undefinedreadonly

Describes the layer's supported capabilities.

effectiveCapabilities

Property
effectiveCapabilities Capabilities |null |undefinedinner,readonly
Since: ArcGIS Maps SDK for JavaScript 4.30 effectiveCapabilities since 4.28, effectiveCapabilities added at 4.30.

Describes effective capabilities of the service taking in to consideration privileges of the currently signed-in user.

layerInfos

Property
layerInfos LayerInfo[]

Contains info of all layers in the Feature Service.

loadError

Property
loadError Error |null |undefinedreadonly

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"

loadWarnings

Property
loadWarnings Object[]readonly

A list of warnings which occurred while loading.

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

tableInfos

Property
tableInfos TableInfo[]

Contains info of all tables in the Feature Service.

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 String |null |undefinedreadonly

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

versionManagementServiceUrl

Property
versionManagementServiceUrl String |null |undefinedreadonly

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

Method Overview

Name Return Type Summary Class

Applies edits to features in the feature service layers.

FeatureService

Cancels a load() operation if it is already in progress.

FeatureService

Triggers the loading of the feature service instance and fetches all layers and tables.

FeatureService

isFulfilled() may be used to verify if creating an instance of the class is fulfilled (either resolved or rejected).

FeatureService

isRejected() may be used to verify if creating an instance of the class is rejected.

FeatureService

isResolved() may be used to verify if creating an instance of the class is resolved.

FeatureService
Promise

Loads the resources referenced by this class.

FeatureService
Promise

Triggers the loading of the feature service instance.

FeatureService
Promise

when() may be leveraged once an instance of the class is created.

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.

The deleteAssociations, combineGroupedObjects, and divideGroupedObjects edits are in beta and are reserved for future use in a telecom domain network.

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
optional
Specification
globalIdField String|null|undefined

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.

deleteAssociations DeleteAssociationEdit[]
optional

An array of objects specifying traditional or foreign-key associations to delete. To delete associations with deleteAssociations, all "from" and "to" properties must be specified in the DeleteAssociationEdit object.

combineGroupedObjects CombineGroupedObjectsEdit[]
optional

An array of objects specifying grouped objects to combine in a telecom domain network. The objects being combined must have consecutive unit IDs, exist in the same table and unit container, and have the same attribute values.

divideGroupedObjects DivideGroupedObjectsEdit[]
optional

An array of objects specifying a grouped objects to divide, and the units to divide the objects into, in a telecom domain network.

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.isDataVersioned 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.

trueCurveClient Boolean
optional

Indicates to the server whether the client is true curve capable. This parameter should be set to true when submitting edits with geometries containing true curves for non-hosted feature services referencing an enterprise geodatabase. By default, this parameter is set to false.

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.

Returns
Type Description
Promise<ServiceEditsResult[]>
  • 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.
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
  }
);

cancelLoad

Method
cancelLoad()

Cancels a load() operation if it is already in progress.

fetchAllLayersAndTables

Method
fetchAllLayersAndTables(){Promise<ServiceContents>}

Triggers the loading of the feature service instance and fetches all layers and tables.

Fully loads the Feature Service definition.

Parameter
options.signal AbortSignal|null|undefined
optional

Signal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named AbortError when an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.

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

isFulfilled

Method
isFulfilled(){Boolean}

isFulfilled() may be used to verify if creating an instance of the class is fulfilled (either resolved or rejected). If it is fulfilled, true will be returned.

Returns
Type Description
Boolean Indicates whether creating an instance of the class has been fulfilled (either resolved or rejected).

isRejected

Method
isRejected(){Boolean}

isRejected() may be used to verify if creating an instance of the class is rejected. If it is rejected, true will be returned.

Returns
Type Description
Boolean Indicates whether creating an instance of the class has been rejected.

isResolved

Method
isResolved(){Boolean}

isResolved() may be used to verify if creating an instance of the class is resolved. If it is resolved, true will be returned.

Returns
Type Description
Boolean Indicates whether creating an instance of the class has been resolved.

load

Method
load(options){Promise}

Loads the resources referenced by this class. This method automatically executes for a View and all of the resources it references in Map if the view is constructed with a map instance.

This method must be called by the developer when accessing a resource that will not be loaded in a View.

The load() method only triggers the loading of the resource the first time it is called. The subsequent calls return the same promise.

It's possible to provide a signal to stop being interested into a Loadable instance load status. When the signal is aborted, the instance does not stop its loading process, only cancelLoad can abort it.

Parameters
optional

Additional options.

Specification
optional

Signal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named AbortError when an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.

Returns
Type Description
Promise Resolves when the resources have loaded.

load

Method
load(options){Promise}

Triggers the loading of the feature service instance.

Fully loads the Feature Service definition.

Parameters
optional

Additional options.

Specification
optional

Signal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named AbortError when an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.

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

when

Method
when(onFulfilled, onRejected){Promise}

when() may be leveraged once an instance of the class is created. This method takes two input parameters: a onFulfilled function and an onRejected function. The onFulfilled executes when the instance of the class loads. The onRejected executes if the instance of the class fails to load.

Parameters
onFulfilled Function
optional

The function to call when the promise resolves.

onRejected Function
optional

The function to execute when the promise fails.

Returns
Type Description
Promise Returns a new promise for the result of onFulfilled that may be used to chain additional functions.
Example
// Although this example uses MapView, any class instance that is a promise may use when() in the same way
let view = new MapView();
view.when(function(){
  // This function will execute once the promise is resolved
}, function(error){
  // This function will execute if the promise is rejected due to an error
});

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
isDataVersioned Boolean

Indicates if the feature service is versioned.

isDataBranchVersioned Boolean

Indicates if the feature service is branch 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|null|undefined

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

maxRecordCountFactor Number|null|undefined

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.

CombineGroupedObjectResult

Type Definition
CombineGroupedObjectResult Object
Since: ArcGIS Maps SDK for JavaScript 4.34 FeatureService since 4.28, CombineGroupedObjectResult added at 4.34.
beta

Represents the result of combining one or more grouped objects in a telecom domain network.

Properties
combinedGlobalId String

The global ID of the object resulting from the combine operation.

deletedGlobalIds String[]

The global IDs of the objects deleted to perform the combination.

CombineGroupedObjectsEdit

Type Definition
CombineGroupedObjectsEdit Object
Since: ArcGIS Maps SDK for JavaScript 4.34 FeatureService since 4.28, CombineGroupedObjectsEdit added at 4.34.
beta

Specifies grouped objects to combine in a telecom domain network.

Property
globalIds String[]

The global IDs of the grouped features to combine. The objects being combined must have consecutive unit IDs, exist in the same table and unit container, and have the same attribute values.

DeleteAssociationEdit

Type Definition
DeleteAssociationEdit Object
Since: ArcGIS Maps SDK for JavaScript 4.34 FeatureService since 4.28, DeleteAssociationEdit added at 4.34.
beta

Specifies a traditional or foreign-key association to delete. To delete a foreign-key association, globalId must be the null GUID {00000000-0000-0000-0000-000000000000}.

Properties
globalId String

The global ID of the association to delete.

associationType String

The type of association.

Possible Values:"connectivity"|"junctionJunctionConnectivity"|"attachment"|"containment"|"junctionEdgeFromConnectivity"|"junctionEdgeMidspanConnectivity"|"junctionEdgeToConnectivity"

fromSourceId Number

The source ID of the "from" feature.

fromGlobalId String

The global ID of the "from" feature.

fromTerminalId Number

The terminal ID of the "from" feature.

toSourceId Number

The source ID of the "to" feature.

toGlobalId String

The global ID of the "to" feature.

toTerminalId Number

The terminal ID of the "to" feature.

DivideGroupedObjectResult

Type Definition
DivideGroupedObjectResult Object
Since: ArcGIS Maps SDK for JavaScript 4.34 FeatureService since 4.28, DivideGroupedObjectResult added at 4.34.
beta

Represents the result of dividing a grouped object in a telecom domain network.

Properties
globalId String

Global ID of the original object before division.

dividedGlobalIds String[]

The global IDs of objects resulting from the division, including the original object. I.e., the GUIDs that the target object was divided into.

connectedEdgeGlobalIds String[]

If the divided object was a junction object that was directly connected to one or more edge objects prior to the division, the edge objects are also divided to maintain connectivity. This array contains GUIDs of any edge objects that are connected to the divided junction objects, including those that were connected prior to the division.

DivideGroupedObjectsEdit

Type Definition
DivideGroupedObjectsEdit Object
Since: ArcGIS Maps SDK for JavaScript 4.34 FeatureService since 4.28, DivideGroupedObjectsEdit added at 4.34.
beta

Specifies a grouped object to divide, and the units to divide the object into.

Properties
globalId String

The global ID of the grouped object to divide.

numUnits Number[]

The units to divide the grouped object into. Each number in this array describes the number of units to assign an object resulting from the division. E.g., to divide one object with 6 units into an object with 5 units and another object with 1 unit, specify [5, 1].

FeatureEditResult

Type Definition
FeatureEditResult Object

Represents the result of editing a feature.

Properties
globalId String|null
optional

Global ID of the feature that was edited.

objectId Number|null
optional

Object ID of the feature that was edited.

error Object|null
optional

If the edit failed, the edit result includes an error.

Specification
name String

Error name.

message String

Message describing the error.

LayerDefinition

Type Definition
LayerDefinition Object
Since: ArcGIS Maps SDK for JavaScript 4.30 FeatureService since 4.28, LayerDefinition added at 4.30.

Contains information for a layer in the Feature Service.

Properties
id Number

The id of a layer.

name String

The name of a layer.

type String

The type of the layer.

url String

The service url of the layer.

geometryType String
optional

The geometry type of a layer.

Possible Values:"point"|"polyline"|"polygon"|"envelope"|"multipoint"

capabilities Capabilities

The capabilities of the layer.

LayerInfo

Type Definition
LayerInfo Object
Since: ArcGIS Maps SDK for JavaScript 4.30 FeatureService since 4.28, LayerInfo added at 4.30.

Contains information for a layer in the Feature Service.

Properties
id Number

The id of a layer.

name String

The name of a layer.

type String

The type of the layer.

url String

The service url of the layer.

geometryType String
optional

The geometry type of a layer.

Possible Values:"point"|"polyline"|"polygon"|"envelope"|"multipoint"

ServiceContents

Type Definition
ServiceContents Object
Since: ArcGIS Maps SDK for JavaScript 4.30 FeatureService since 4.28, ServiceContents added at 4.30.

Contains information returned from the service containing layerInfos, tableInfos, and server capabilities.

Properties

Contains the Layer Definition of a layer.

Contains the Table Definition of a layer.

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 FeatureEditResult[]

Results returned from an add operation.

updateFeatureResults FeatureEditResult[]

Results returned from an update operation.

deleteFeatureResults FeatureEditResult[]

Results returned from a delete operation.

addAttachmentResults FeatureEditResult[]

Results returned from an add attachments operation.

updateAttachmentResults FeatureEditResult[]

Results returned from an update attachments operation.

deleteAttachmentResults FeatureEditResult[]

Results returned from a delete attachments operation.

divideGroupedObjectResults DivideGroupedObjectResult[]
optional

Results returned from a divide operation.

combineGroupedObjectResults CombineGroupedObjectResult[]
optional

Results returned from a combine operation.

splitsResults SplitsResult[]
optional

Results returned from a split operation.

editedFeatures Object
optional

Object containing all edited features belonging to the specified layer.

editMoment Number
optional

Returns the editMoment of an edit.

SplitsResult

Type Definition
SplitsResult Object

Represents the result of a split operation.

Properties
objectId Number

The object ID of the feature that was split.

results Number[]

The object ID of the original feature and the feature(s) created from the split.

TableDefinition

Type Definition
TableDefinition Object
Since: ArcGIS Maps SDK for JavaScript 4.30 FeatureService since 4.28, TableDefinition added at 4.30.

Contains information for a table in the Feature Service.

Properties
id Number

The id of a table.

name String

The name of a table.

type String

The type of the table.

url String

The service url of the table.

capabilities Capabilities

The capabilities of the table.

TableInfo

Type Definition
TableInfo Object
Since: ArcGIS Maps SDK for JavaScript 4.30 FeatureService since 4.28, TableInfo added at 4.30.

Contains information for a table in the Feature Service.

Properties
id Number

The id of a table.

name String

The name of a table.

type String

The type of the table.

url String

The service url of the table.

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