# Get Record Create Defaults

| AVAILABLE API VERSION |
| --------------------- |
| API v68.0 and later   |

The `recordCreateDefaults` field of `CreateDefaultsConnection` type returns default field values for a new record of a given object type. The response includes the pre-populated field values that a user sees when opening a blank create form in the Salesforce user interface. This feature mirrors the behavior of the UI API [Get Default Values to Create a Record](https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_resources_record_defaults_create.htm) and [Get Default Values to Create a Record—Lightweight](https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_resources_record_defaults_template_create.htm) resources. If you need object info or layout structure, chain separate calls to [`objectInfo`](/docs/platform/graphql/guide/query-objectinfo.md) and [`recordLayouts`](/docs/platform/graphql/guide/query-record-layouts.md) to get everything necessary to render a pre-populated create form.

Pass `recordCreateDefaults` in the `uiapi` field. For example, use `objectApiName: "Account"` to return the default field values for a new account record.

```sfdocs-code {"lang":"graphql", "title": "Query recordCreateDefaults Field", "src": "" }
{
  uiapi {
    recordCreateDefaults(objectApiName: "Account") {
      # fields
    }
  }
}
```

## Record Create Defaults Schema

Query `recordCreateDefaults` by using this schema.

```sfdocs-code {"lang":"graphql", "title": "Query recordCreateDefaults", "src": "" }
type UIAPI {
   recordCreateDefaults(
      objectApiName: String!
      recordTypeIds: [ID!]
      formFactor = "LARGE": FormFactor
      mode = "LAYOUT": CreateDefaultsMode
      configs: [CreateDefaultsConfig!]
      optionalFields: [String!]
      first: Int
      after: String
   ): CreateDefaultsConnection
}

input CreateDefaultsConfig {
   recordTypeId: ID!
   formFactor = "LARGE": FormFactor
}
```

The `recordCreateDefaults` type has these arguments.

- `objectApiName` - The object API name of a [supported object](https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_all_supported_objects.htm). This argument is required.

- `recordTypeIds` - A list of record type IDs. If unspecified, returns defaults for all accessible record types. Specify either `recordTypeIds` or `configs`.

- `formFactor` - Default form factor that the [FormFactor enum](#formfactor) provides for all layouts. Default value is `LARGE`. This argument is ignored when the `mode` value is `TEMPLATE`.

- `mode` - The mode that the [CreateDefaultsMode enum](#createdefaultsmode) provides. Controls whether to return all CREATE layout fields (`LAYOUT`) or only requested fields (`TEMPLATE`). Default value is `LAYOUT`. To discover which fields appear in `LAYOUT` mode, [get object layouts](/docs/platform/graphql/guide/query-record-layouts.md) with `mode: CREATE`.

- `configs` - An array of `CreateDefaultsConfig` types with these arguments to request different form factor combinations per record type. Specify either `configs` or `recordTypeIds`.

  - `recordTypeId` - A record type ID. This argument is required.
  - `formFactor` - Form factor that the [FormFactor enum](#formfactor) provides for the record type. Default value is `LARGE`.

- `optionalFields` - A list of additional field API names to include in the response alongside the fields determined by `mode`. Useful when `mode` is `TEMPLATE` to specify exactly which fields to return.

- `first` - Number of results per page. Default value is `10`.

- `after` - Returns the results after the given cursor. See [Paginate Results](/docs/platform/graphql/guide/paginate.md).

## CreateDefaultsConnection Type

The `CreateDefaultsConnection` type represents a result set of record create defaults that ties together the defaults and page info. Results are paginated by record type, with each edge representing one set of defaults for one record type. See [Paginate Results](/docs/platform/graphql/guide/paginate.md).

```sfdocs-code {"lang":"graphql", "title": "CreateDefaultsConnection Type", "src": "" }
type CreateDefaultsConnection {
  edges: [CreateDefaultsEdge]
  pageInfo: PageInfo!
  totalCount: Int
}
```

The `CreateDefaultsConnection` type contains these fields.

- `edges` - A list of CreateDefaultsEdge types.
- `pageInfo` - Information about the relative location in the result set.
- `totalCount` - The total number of `recordTypeId` and `formFactor` pair results.

## CreateDefaultsEdge Type

The `CreateDefaultsEdge` type ties together the create defaults node and its cursor.

```sfdocs-code {"lang":"graphql", "title": "CreateDefaultsEdge Type", "src": "" }
type CreateDefaultsEdge {
  node: CreateDefaults
  cursor: String!
}
```

The `CreateDefaultsEdge` type contains these fields.

- `node` - One set of create defaults for one record type.
- `cursor` - An opaque string used to page directly to this item in the result set.

## CreateDefaults Type

The `CreateDefaults` type is the set of default field values for the record type.

```sfdocs-code {"lang":"graphql", "title": "CreateDefaults Type", "src": "" }
type CreateDefaults {
  recordTypeId: ID
  formFactor: FormFactor
  fields: [FieldDefault!]!
}
```

The `CreateDefaults` type contains these fields.

- `recordTypeId` - Resolved record type ID, which can differ from the requested ID if the object has a default record type and none was specified.
- `formFactor` - Form factor that the [FormFactor enum](#formfactor) provides for this set of defaults.
- `fields` - A list of FieldDefault types containing the default value for each field.

## FieldDefault Type

The `FieldDefault` type represents a single field and its default value.

```sfdocs-code {"lang":"graphql", "title": "FieldDefault Type", "src": "" }
type FieldDefault {
  apiName: String!
  rawValue: String
  value: FieldDefaultValue
}
```

The `FieldDefault` type contains these fields.

- `apiName` - The API name of the field.
- `rawValue` - The raw string representation of the default value. Null if the field has no default and for relationship traversal fields.
- `value` - The typed default value. The [FieldDefaultValue union](#fielddefaultvalue-union) provides the concrete value type.

## FieldDefaultValue Union

The `FieldDefaultValue` union represents the typed value for a field default. Use inline fragments to access the fields of each concrete type.

```sfdocs-code {"lang":"graphql", "title": "FieldDefaultValue Union", "src": "" }
union FieldDefaultValue =
    StringValue
    IntValue
    BooleanValue
    IDValue
    DateValue
    DateTimeValue
    TimeValue
    TextAreaValue
    LongTextAreaValue
    RichTextAreaValue
    PhoneNumberValue
    EmailValue
    UrlValue
    EncryptedStringValue
    CurrencyValue
    LongitudeValue
    LatitudeValue
    PicklistValue
    MultiPicklistValue
    LongValue
    DoubleValue
    PercentValue
    Base64Value
    JSONValue
    FieldDefaultReferenceValue
```

Most `FieldDefaultValue` member types implement the `FieldValue` interface and expose a `value` field and a `displayValue` field. Use inline fragments to query type-specific fields. For example, `... on StringValue { value displayValue }`. See [Fields](/docs/platform/graphql/guide/query-record-objects.md#fields) for more information about Field Value types.

## FieldDefaultReferenceValue Type

The `FieldDefaultReferenceValue` type is the resolved reference record info for a relationship traversal field, such as owner or parent.

```sfdocs-code {"lang":"graphql", "title": "FieldDefaultReferenceValue Type", "src": "" }
type FieldDefaultReferenceValue {
  id: ID
  displayValue: String
  objectApiName: String
}
```

The `FieldDefaultReferenceValue` type contains these fields.

- `id` - The ID of the referenced record.
- `displayValue` - The display name of the referenced record.
- `objectApiName` - The object API name of the referenced record’s type.

## PageInfo Type

The `PageInfo` type contains relative position information, which shows where in the entire result set the current page is located. The `PageInfo` type is the same for every `Connection` type. See [PageInfo Type](/docs/platform/graphql/guide/query-record-objects.md#pageinfo-type).

## Enumeration Types

The `recordCreateDefaults` type has these enumerations.

### CreateDefaultsMode

The `CreateDefaultsMode` enumeration controls which fields are returned.

```sfdocs-code {"lang":"graphql", "title": "CreateDefaultsMode Enum", "src": "" }
enum CreateDefaultsMode {
  LAYOUT
  TEMPLATE
}
```

- `LAYOUT` - Returns all fields from the object’s CREATE page layout. This is the default.
- `TEMPLATE` - Returns only the fields specified in the `optionalFields` argument.

### FormFactor

The `FormFactor` enumeration specifies the layout display size. Use the `LARGE` value for desktop, the `MEDIUM` value for tablet, and the `SMALL` value for phone. See [FormFactor](/docs/platform/graphql/guide/query-record-layouts.md#formfactor).

## See Also

[Get Record Create Defaults Examples](/docs/platform/graphql/guide/query-record-create-defaults-examples.md)
