Get Object Metadata Examples

AVAILABLE API VERSION
API v56.0 and later
Locale available in API v60.0 and later
Picklist values available in API v65.0 and later

Query Account Object Metadata 

This example fetches the metadata for the Account object.

Query Account ObjectInfo
1{
2  uiapi {
3    objectInfos(apiNames: ["Account"]) {
4      ApiName
5      childRelationships {
6        fieldName
7        childObjectApiName
8        junctionIdListNames
9        junctionReferenceTo
10        relationshipName
11
12      }
13      createable
14      custom
15      defaultRecordTypeId
16      deletable
17      dependentFields {
18        controllingField
19        dependentFields
20      }
21      feedEnabled
22      fields {
23        ApiName
24        calculated
25        compound
26        compoundComponentName
27        controllerName
28        controllingFields
29        createable
30        custom
31        dataType
32        extraTypeInfo
33        filterable
34        filteredLookupInfo {
35          controllingFields
36          dependent
37          optionalFilter
38        }
39        highScaleNumber
40        htmlFormatted
41        inlineHelpText
42        label
43        nameField
44        polymorphicForeignKey
45        precision
46        reference
47        referenceToInfos {
48          ApiName
49          nameFields
50        }
51        relationshipName
52        referenceTargetField
53        scale
54        sortable
55        searchPrefilterable
56        updateable
57      }
58      keyPrefix
59      label
60      labelPlural
61      layoutable
62      mruEnabled
63      nameFields
64      queryable
65      recordTypeInfos {
66        name
67        recordTypeId
68      }
69      searchable
70      themeInfo {
71        color
72        iconUrl
73      }
74      updateable
75    }
76  }
77}

The previous query returns this response.

Response for Account ObjectInfo Query
1{
2  "data": {
3    "uiapi": {
4      "objectInfos": [
5        {
6          "ApiName": "Account",
7          "childRelationships": [
8            {
9              "fieldName": "ParentId",
10              "childObjectApiName": "Account",
11              "junctionIdListNames": [],
12              "junctionReferenceTo": [],
13              "relationshipName": "ChildAccounts"
14            },
15            //...truncated for display
16          "createable": true,
17          "custom": false,
18          "defaultRecordTypeId": null,
19          "deletable": true,
20          "dependentFields": [],
21          "feedEnabled": true,
22          "fields": [
23            {
24              "ApiName": "ShippingLatitude",
25              "calculated": false,
26              "compound": false,
27              "compoundComponentName": "ShippingAddress",
28              "controllerName": null,
29              "controllingFields": [],
30              "createable": true,
31              "custom": false,
32              "dataType": "DOUBLE",
33              "extraTypeInfo": null,
34              "filterable": true,
35              "filteredLookupInfo": null,
36              "highScaleNumber": false,
37              "htmlFormatted": false,
38              "inlineHelpText": null,
39              "label": "Shipping Latitude",
40              "nameField": false,
41              "polymorphicForeignKey": false,
42              "precision": 18,
43              "reference": false,
44              "referenceToInfos": [],
45              "relationshipName": null,
46              "referenceTargetField": null,
47              "scale": 15,
48              "sortable": true,
49              "searchPrefilterable": false,
50              "updateable": true
51            },
52            //...truncated for display
53            "keyPrefix": "001",
54            "label": "Account",
55            "labelPlural": "Accounts",
56            "layoutable": true,
57            "mruEnabled": true,
58            "nameFields": [
59              "Name"
60            ],
61            "queryable": true,
62            "recordTypeInfos": [
63              {
64                "name": "Master",
65                "recordTypeId": "012000000000000AAA"
66              }
67            ],
68            "searchable": true,
69            "themeInfo": {
70              "color": "7F8DE1",
71              "iconUrl": "https://www.example.com/img/account_120.png"
72            },
73            "updateable": true
74          }
75       ]
76     }
77  },
78  "errors": []
79}

Query Account Object Labels Using a Locale 

This example gets account labels in French.

Query objectInfos with locale
1query accounts {
2    uiapi {
3         objectInfos(apiNames: ["Account"], locale: "fr_FR") {
4           ApiName
5           locale
6           fields {
7             label
8           }
9         }
10    }
11}

The previous query returns this response.

Response for objectInfos with locale Query
1{
2  "data": {
3    "uiapi": {
4      "objectInfos": [
5        {
6          "ApiName": "Account",
7          "locale": "fr_FR",
8          "fields": [
9            {
10              "label": "Date de dernière modification"
11            },
12            {
13              "label": "Ville de facturation"
14            },
15            {
16              "label": "Jigsaw Company ID"
17            },
18            {
19              "label": "SLA"
20            },
21          :
22          :
23          ]
24        }
25      ]
26    }
27  }
28}

Query Picklist Values for a Record Type 

This example gets all picklist values for the Account object for a specified record type ID.

Query Picklist Values for a Record Type
1query GetPicklistValuesByRecordType {
2  uiapi {
3    objectInfos(objectInfoInputs: {
4      apiName: "Account",
5      recordTypeIDs: ["012000000000000AAA"],
6      fieldNames: []
7    }) {
8      apiName
9      fields {
10        apiName
11        ... on PicklistField {
12          picklistValuesByRecordTypeIDs {
13            recordTypeID
14            controllerValues {
15              value
16            }
17            picklistValues {
18              value
19            }
20          }
21        }
22      }
23    }
24  }
25}

The previous query returns this response.

Response for Picklist Values for a Record Type Query
1{
2  "data": {
3    "uiapi": {
4      "objectInfos": [
5        {
6          "apiName": "Account",
7          "fields": [
8            {
9              "apiName": "Industry",
10              "picklistValuesByRecordTypeIDs": [
11                {
12                  "recordTypeID": "012000000000000AAA",
13                  "controllerValues": [],
14                  "picklistValues": [
15                    { "value": "Agriculture" },
16                    { "value": "Apparel" },
17                    ...
18                  ]
19                }
20              ]
21            },
22            ...
23          ]
24        }
25      ]
26    }
27  }
28}

Query Picklist Values for Multiple Record Types 

This example gets all picklist values for two record type IDs and filtered by a field name.

Query Picklist Values for Multiple Record Types
1query GetFilteredPicklistValues {
2  uiapi {
3    objectInfos(objectInfoInputs: {
4      apiName: "Account",
5      recordTypeIDs: ["012000000000000AAA", "012xx0000006ZD2AAM"],
6      fieldNames: ["Industry"]
7    }) {
8      apiName
9      fields {
10        apiName
11        ... on PicklistField {
12          picklistValuesByRecordTypeIDs {
13            recordTypeID
14            controllerValues {
15              value
16            }
17            picklistValues {
18              value
19            }
20          }
21        }
22      }
23    }
24  }
25}

The previous query returns this response.

Response for Picklist Values with Multiple Record Types Query
1{
2  "data": {
3    "uiapi": {
4      "objectInfos": [
5        {
6          "apiName": "Account",
7          "fields": [
8            {
9              "apiName": "Industry",
10              "picklistValuesByRecordTypeIDs": [
11                {
12                  "recordTypeID": "012000000000000AAA",
13                  "controllerValues": [],
14                  "picklistValues": [
15                    { "value": "Agriculture" },
16                    { "value": "Apparel" },
17                    ...
18                  ]
19                },
20                {
21                  "recordTypeID": "012xx0000006ZD2AAM",
22                  "controllerValues": [],
23                  "picklistValues": [
24                    { "value": "Agriculture" },
25                    { "value": "Apparel" },
26                    ...
27                  ]
28                }
29              ]
30            }
31          ]
32        }
33      ]
34    }
35  }
36}

Query Account Child Relationships 

This example fetches all the child relationships for the Account object.

Query childRelationships on Account
1{
2  uiapi {
3    objectInfos(apiNames: ["Account"]) {
4      childRelationships {
5        objectInfo {
6          ApiName
7          createable
8          custom
9          defaultRecordTypeId
10          deletable
11          feedEnabled
12          keyPrefix
13          label
14          labelPlural
15          layoutable
16          mruEnabled
17          nameFields
18          queryable
19          searchable
20          updateable
21        }
22      }
23    }
24  }
25}

The previous query returns this response.

Response for Account childRelationship Query
1{
2  "data": {
3    "uiapi": {
4      "objectInfos": [
5        {
6          "childRelationships": [
7            {
8              "objectInfo": {
9                "ApiName": "Account",
10                "createable": true,
11                "custom": false,
12                "defaultRecordTypeId": null,
13                "deletable": true,
14                "feedEnabled": true,
15                "keyPrefix": "001",
16                "label": "Account",
17                "labelPlural": "Accounts",
18                "layoutable": true,
19                "mruEnabled": true,
20                "nameFields": [
21                  "Name"
22                ],
23                "queryable": true,
24                "searchable": true,
25                "updateable": true
26              }
27            },
28            {
29              "objectInfo": {
30                "ApiName": "AccountChangeEvent",
31                "createable": false,
32                "custom": false,
33                "defaultRecordTypeId": null,
34                "deletable": false,
35                "feedEnabled": false,
36                "keyPrefix": "1CE",
37                "label": "Account Change Event",
38                "labelPlural": "Account Change Event",
39                "layoutable": false,
40                "mruEnabled": false,
41                "nameFields": [
42                  "Name"
43                ],
44                "queryable": false,
45                "searchable": false,
46                "updateable": false
47              }
48            },
49            //...truncated for display
50            {
51              "objectInfo": {
52                "ApiName": "WorkOrderChangeEvent",
53                "createable": false,
54                "custom": false,
55                "defaultRecordTypeId": null,
56                "deletable": false,
57                "feedEnabled": false,
58                "keyPrefix": "1CE",
59                "label": "Work Order Change Event",
60                "labelPlural": "Work Order Change Event",
61                "layoutable": false,
62                "mruEnabled": false,
63                "nameFields": [],
64                "queryable": false,
65                "searchable": false,
66                "updateable": false
67              }
68            }
69          ]
70        }
71      ]
72    }
73  },
74  "errors": []
75}

Query Child Relationships for Account and Case 

This example returns the child relationships for accounts and cases. It also runs an objectInfo subquery to fetch the queryable field on childRelationships.

Query Account and Case Child Relationships
1{
2  uiapi {
3    objectInfos(apiNames: ["Account", "Case"]) {
4      ApiName
5      childRelationships {
6        childObjectApiName
7        relationshipName
8        objectInfo {
9          ApiName
10          queryable
11        }
12      }
13    }
14  }
15}

The previous query returns this response.

Response for Account and Case Child Relationships Query
1{
2  "data": {
3    "uiapi": {
4      "objectInfos": [
5        {
6          "ApiName": "Account",
7          "childRelationships": [
8            {
9              "childObjectApiName": "Account",
10              "relationshipName": "ChildAccounts",
11              "objectInfo": {
12                "ApiName": "Account",
13                "queryable": true
14              }
15            },
16            //...truncated for display
17          ]
18        }
19      ]
20    }
21  }
22}

See Also 

Get Object Metadata