- URL:
- https://<root>/<serviceName>/FeatureServer/<layerId>/calculate
- Methods:
- GET
- Required Capability:
- Update
- Version Introduced:
- 10.4
Description
The calculate  operation is performed on a feature service layer resource. It updates the values of one or more fields in an existing feature service layer based on SQL expressions or scalar values.
A layer is capable of supporting the calculate  operation if the supports  property is true . If the property is false , or not present, the layer is not capable of supporting this operation. When the property is true , a client can use the calculate  operation as long as the Update  capability is set on the feature service, or if the user is logged in as the service owner, view owner, or organization administrator.
If supports  is true  and is  is also true , the gdb  parameter is supported. If supports  is true  and is  is also true , the session  and return  parameters are supported.
Neither the Shape  field nor system fields can be updated using the calculate  operation. System fields include Object  and Global .
See Calculate a field for more information on supported expressions.
Request parameters
| Parameter | Details | 
|---|---|
| 
 (Optional) | A where clause can be used to limit the updated records. Any legal SQL where clause operating on the fields in the layer is allowed. If this parameter is not included in the request, the operation will apply to all records. The  You can set the  Examples  | 
| 
 | The array of field/value info objects that contain the field or fields to update and their scalar values or SQL expression. For more information on how to build expressions, see Calculate a field. If you are updating records in a date type field, be sure to issue the new date or time value in UTC. This is the case even if you have the  Syntax Examples  | 
| 
 | The SQL format for the  The  Values:  | 
| 
 | The geodatabase version to apply the edits. This parameter applies only if the  Syntax Example  | 
| 
 (Optional) | Set by a client during long transaction editing on a branch version. The  Syntax  | 
| 
 (Optional) | Specifies whether the response will report the time edits were applied. If  Values:   | 
| 
 | Indicates whether to process the calculate operation in synchronous or asynchronous mode. This parameter can only be set to  If possible, it's recommended that you set the  Values:  Example  | 
| 
 | The response format. The default response format is  Values:  | 
JSON Response syntax
When async  is false :
{
  "success": <true|false>,
  "updatedFeatureCount": <count>,
  "editMoment": <epochMilliseconds>
}When async  is true :
{
  "statusUrl": "<statusURL>"
}JSON Response examples
When async  is false :
{
   "success": true,
   "updatedFeatureCount": 51
}When async  is false , data is branch versioned, and return  is true :
{
  "success":true,
  "updatedFeatureCount":51,
  "editMoment": 1457994488000
}When async  is true :
{
  "status": "Completed",
  "submissionTime": 1572816329000,
  "lastUpdatedTime": 1572816344000,
  "recordCount": 3140
}