- URL:
- https://<layer-url>/queryRelatedRecords
- Methods:
GET- Required Capability:
- Data
- Version Introduced:
- 10.0
Description
The query related records operation is performed on a layer / table resource. The result of this operation is one or more featuresets grouped by source layer / table object IDs. Each featureset 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 featureset. For related tables, the featureset does not include geometries.
Also, each featureset contains an array of field information objects for fields requested in out parameter. See Layer/Table for details on fields.
You can provide arguments to the query related records operation as query parameters defined in the parameters table below.
New at 11.3
- This operation introduces two new parameters i.e.
resultandRecord Count resultto support pagination for map services query related records results. Support for pagination is indicated when the layer-levelOffset supportsproperty, underQuery Related Pagination advanced, isQuery Capabilities true. - Map services now support the
orderandB y returnparameters. Support for these parameters is indicated when the layer-levelCount Only supportsproperty, underAdvanced Query Related advanced, isQuery Capabilities true.
New in 10.5
- The feature service layer Query operation supports the
returnandTrue Curves historicparameters.Moment
New in 10.1
- Support for
returnandZ returnwas added for layers. Default value forM returnandZ returnis false.M - Support for
gdbparameter was added. Use this parameter to specify the geodatabase version to query.Version geometryparameter was introduced. This option can be used to specify the number of decimal places in the response geometries returned by the query operation.Precision - JSON response contains an optional property
exceeded. This property will be true only if the number of records exceeds the maximum number configured by the server administrator.Transfer Limit
Request parameters
| Parameter | Details |
|---|---|
| The object IDs of this layer/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/layer to be included in the returned featureset. 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/layer. From the list of records that are related to the specified Example |
| If Values: |
| This option was added at 10.0. This option can be used to specify the Example |
| This option was added at 10.1. This option can be used to specify the number of decimal places in the response geometries returned by the Example |
| This option was added at 10.5 and works with ArcGIS Enterprise services only. The historic moment to query. This parameter applies only if the Syntax Example |
| The spatial reference of the returned geometry. The spatial reference can be specified as either a well-known ID or as a spatial reference json object. If |
| This option was added at 10.1. If Values: |
| This option was added at 10.1. If Values: |
| This option was added at 10.5. Optional parameter that is Values: |
| This option was added at 10.1. GeoDatabase version to query. This parameter applies only if Syntax Example |
| This option can be used for fetching query results up to the Example |
| This option can be used for fetching query results by skipping the specified number of records and starting from the next record (that is, Example |
| This parameter is used to request a list of the related records based on the field order. This list is a comma delimited list of field names. When Syntax Example |
| If Values: Example |
| The response format. The default response format is Values: |
Example usage
https://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/0/queryRelatedRecords?objectIds=3,4,5&relationshipId=2&returnGeometry=true&outFields=*&f=htmlExample one
The following is a sample request URL for the query operation, which requests to skip the first two records and return the next four records where the objectId is greater than 3:
https://machine.domain.com/webadaptor/rest/services/RelationshipOID_test/MapServer/3/queryRelatedRecords?objectIds=&relationshipId=1&outFields=*&definitionExpression=ObjectID>3&returnGeometry=true&resultOffset=2&resultRecordCount=4&f=htmlExample two
The following is a sample request URL for the query operation, which will return the related records count for each specified objectId where TOWNSHIP is the value for order :
https://machine.domain.com/webadaptor/rest/services/KSPetro/MapServer/1/queryRelatedRecords?objectIds=70,71,62&relationshipId=1&outFields=*&orderByFields=TOWNSHIP&returnCountOnly=true&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 examples
{
"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
]
]
]
}
}
]
}
]
}{
"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
]
]
]
}
}
]
}
]
}