- URL:
- https://<dynamic-layer-url>/queryRelatedRecords
- Methods:
- GET
- Required Capability:
- Data
- Version Introduced:
- 10.1
Description
The query-related records operation is performed on a  dynamic layer / table resource, of type map . The result of this operation is one or more feature sets grouped by source layer / table object IDs. Each feature set contains feature objects including the values for the fields requested by the user. For related layers, if you request geometry information, the geometry of each feature is also returned in the feature set. For related tables, the feature set does not include geometries.
You can provide arguments to the query-related records operation as query parameters defined in the parameters table below.
New at 10.5
- Supports datum transformation.
Request parameters
| Parameter | Details | 
|---|---|
| 
 (Required) | Defines a dynamic layer. Only dynamic map layers are supported. When using this parameter, keep the following in mind: 
 Example  | 
| 
 | The object IDs of this layer or table to be queried. Records related to these object IDs will be queried. Syntax Example  | 
| 
 | The ID of the relationship to be queried. The  Example  | 
| 
 | The list of fields from the related table or layer to be included in the returned feature set. This list is a comma-delimited list of field names. If you specify the shape field in the list of return fields, it is ignored. To request geometry, set  Example  | 
| 
 | The definition expression to be applied to the related table or layer. From the list of records that are related to the specified  Example  | 
| 
 | If  | 
| 
 | Added at 10.0. Specifies the  Example  | 
| 
 | Specifies the number of decimal places in the response geometries by the  Example  | 
| 
 | Specifies the spatial reference of the returned geometry. The spatial reference can be specified as a well-known ID or as a spatial reference json object. If  | 
| 
 | If  Values:  | 
| 
 | If  Values:  | 
| 
 | Added at 10.5. Applies a datum transformation while projecting geometries in the results when  For a list of valid datum transformation ID values and well-known text strings, see Using spatial references. For more information on datum transformation, see the  Syntax Examples  | 
| 
 | The response format. The default response format is  Values:  | 
Example usage
The following is a sample request URL for the query  operation:
https://organization.example.com/<context>/rest/services/Petroleum/KSPetro/MapServer/dynamicLayer/queryRelatedRecords?layer={"id":101,"definitionExpression":"\"sub_region\" like 'Pacific'","source":{"type":"mapLayer","mapLayerId":3}}&objectIds=3,4,5&relationshipId=2&returnGeometry=true&outFields=*&f=htmlJSON Response syntax
{
  "geometryType": "<geometryType>", //if records include geometry
  "spatialReference": <spatialReference>, //if records include geometry
  "hasZ": <true|false>, //added in 10.1
  "hasM": <true|false>, //added in 10.1
  "fields": [
    {
      "name": "<fieldName1>",
      "type": "<fieldType1>",
      "alias": "<fieldAlias1>",
      "length": "<length1>"
    },
    {
      "name": "<fieldName2>",
      "type": "<fieldType2>",
      "alias": "<fieldAlias2>",
      "length": "<length2>"
    }
  ],
  "relatedRecordGroups": [
    {
      "objectId": <objectId1>,
      "relatedRecords": [ //features may include geometry for related layers only
        <relatedFeature11>,
        <relatedFeature12>
      ]
    },
    {
      "objectId": <objectId2>,
      "relatedRecords": [
        <relatedFeature21>,
        <relatedFeature22>
      ]
    }
  ]
}JSON Response example
When viewing the JSON response for your request, keep the following in mind:
- The domainsmember is not included in field information objects returned with the response.
- The JSON response contains an optional property exceeded. This property will be true only if the number of records exceeds the maximum number configured by an administrator.Transfer Limit 
{
  "geometryType": "esriGeometryPolygon",
  "spatialReference": {
    "wkid": 4267
  },
  "fields": [
    {
      "name": "OBJECTID",
      "type": "esriFieldTypeOID",
      "alias": "OBJECTID"
    },
    {
      "name": "FIELD_KID",
      "type": "esriFieldTypeString",
      "alias": "FIELD_KID",
      "length": 25
    },
    {
      "name": "APPROXACRE",
      "type": "esriFieldTypeDouble",
      "alias": "APPROXACRE"
    },
    {
      "name": "FIELD_NAME",
      "type": "esriFieldTypeString",
      "alias": "FIELD_NAME",
      "length": 150
    }
  ],
  "relatedRecordGroups": [
    {
      "objectId": 3,
      "relatedRecords": [
        {
          "attributes": {
            "OBJECTID": 5540,
            "FIELD_KID": "1000147595",
            "APPROXACRE": 95929,
            "FIELD_NAME": "LOST SPRINGS",
          },
          "geometry": {
            "rings": [
              [
                [
                  -96.929599633999942,
                  38.52426809800005
                ],
                [
                  -96.929602437999961,
                  38.522448437000037
                ],
                [
                  -96.92959118999994,
                  38.529723252000053
                ],
                [
                  -96.929594022999936,
                  38.527905578000059
                ],
                [
                  -96.929596839999988,
                  38.526087119000067
                ],
                [
                  -96.929599633999942,
                  38.52426809800005
                ]
              ]
            ]
          }
        }
      ]
    }
  ]
}