---
schema_version: "1"
id: f41ec8940d42a5602cd7968f5e5bd36f32cba63d4abdcd8f3713f2c7a3b77ee6
title: Get Record Create Defaults Examples
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/graphql-api/graphql/guides/query/query-record-create-defaults-examples.md
canonical_url: https://developer.salesforce.com/docs/platform/graphql/guide/query-record-create-defaults-examples.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 3b01a0434695849d44bd45d8844ef84e4cfed6ad1d52364d86ae896ef28e8577
products:
  - GraphQL API
---
# Get Record Create Defaults Examples

| AVAILABLE API VERSION |
| --------------------- |
| API v68.0 and later   |

## Get Create Defaults for an Object

This example gets the default field values for creating an account record. Use `rawValue` for scalar fields. Use a single [inline fragment](https://graphql.org/learn/queries/#inline-fragments) with the `... on Object` syntax for reference fields.

```
{
  uiapi {
    recordCreateDefaults(objectApiName: "Account") {
      edges {
        node {
          recordTypeId
          formFactor
          fields {
            apiName
            rawValue
            value {
              __typename
              ... on FieldDefaultReferenceValue {
                id
                displayValue
                objectApiName
              }
            }
          }
        }
      }
      pageInfo {
        hasNextPage
        endCursor
      }
    }
  }
}
```

The previous query returns this partial response.

```
{
  "edges": [
    {
      "node": {
        "recordTypeId": "012000000000000AAA",
        "formFactor": "LARGE",
        "fields": [
          { "apiName": "OwnerId",  "rawValue": "005xx000001X7oXAAS", "value": { "__typename": "IDValue" } },
          { "apiName": "Owner",    "rawValue": null,                  "value": { "__typename": "FieldDefaultReferenceValue", "id": "005xx000001X7oXAAS", "displayValue": "Admin User", "objectApiName": "User" } },
          { "apiName": "Name",     "rawValue": null,                  "value": { "__typename": "StringValue" } },
          { "apiName": "Industry", "rawValue": null,                  "value": { "__typename": "PicklistValue" } }
        ]
      }
    }
  ]
}
```

## Get Create Defaults with Typed Field Values

This example gets the default field values for a new opportunity record with a reusable fragment to get the typed value for each field.

```
fragment FieldDefaultFragment on FieldDefault {
  apiName
  rawValue
  value {
    __typename
    ... on IDValue            { id:   value }
    ... on StringValue        { s:    value }
    ... on BooleanValue       { b:    value }
    ... on IntValue           { i:    value }
    ... on LongValue          { l:    value }
    ... on DoubleValue        { d:    value }
    ... on PercentValue       { pct:  value }
    ... on CurrencyValue      { cv:   value }
    ... on DateValue          { date: value }
    ... on DateTimeValue      { dt:   value }
    ... on TimeValue          { time: value }
    ... on TextAreaValue      { t:    value }
    ... on LongTextAreaValue  { lta:  value }
    ... on UrlValue           { u:    value }
    ... on PicklistValue      { p:    value }
    ... on MultiPicklistValue { mp:   value }
    ... on LongitudeValue     { lov:  value }
    ... on LatitudeValue      { lav:  value }
    ... on FieldDefaultReferenceValue { id displayValue objectApiName }
  }
}

{
  uiapi {
    recordCreateDefaults(objectApiName: "Opportunity") {
      edges {
        node {
          recordTypeId
          formFactor
          fields {
            ...FieldDefaultFragment
          }
        }
      }
    }
  }
}
```

## Get Create Defaults in Template Mode

This example uses `TEMPLATE` mode with `optionalFields` to return defaults only for the specified fields on the opportunity object.

```
{
  uiapi {
    recordCreateDefaults(
      objectApiName:  "Opportunity"
      mode:           TEMPLATE
      optionalFields: ["Opportunity.Name", "Opportunity.StageName", "Opportunity.CloseDate", "Opportunity.OwnerId"]
    ) {
      edges {
        node {
          recordTypeId
          fields {
            apiName
            rawValue
            value {
              __typename
              ... on FieldDefaultReferenceValue {
                id
                displayValue
                objectApiName
              }
            }
          }
        }
      }
    }
  }
}
```

## Get Create Defaults and Layout

This example chains getting account create defaults with the account layout to minimize round trips. The two fields share multiple arguments, such as `objectApiName` and `recordTypeId`, and require consistency in query.

```
{
  uiapi {
    recordLayouts(
      objectApiName: "Account"
      mode:          CREATE
      formFactor:    LARGE
    ) {
      edges {
        node {
          recordTypeId
          sections {
            heading
            layoutRows {
              layoutItems {
                label
                required
                editableForNew
                layoutComponents {
                  apiName
                  componentType
                }
              }
            }
          }
        }
      }
    }

    recordCreateDefaults(objectApiName: "Account") {
      edges {
        node {
          recordTypeId
          fields {
            apiName
            rawValue
            value {
              __typename
              ... on FieldDefaultReferenceValue { id displayValue objectApiName }
            }
          }
        }
      }
    }
  }
}
```

## See Also

[Get Record Create Defaults](https://developer.salesforce.com/docs/platform/graphql/guide/query-record-create-defaults.md)
