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 and Get Default Values to Create a Record—Lightweight resources. If you need object info or layout structure, chain separate calls to objectInfo and recordLayouts 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.

Query recordCreateDefaults Field
1{
2  uiapi {
3    recordCreateDefaults(objectApiName: "Account") {
4      # fields
5    }
6  }
7}

Record Create Defaults Schema 

Query recordCreateDefaults by using this schema.

Query recordCreateDefaults
1type UIAPI {
2   recordCreateDefaults(
3      objectApiName: String!
4      recordTypeIds: [ID!]
5      formFactor = "LARGE": FormFactor
6      mode = "LAYOUT": CreateDefaultsMode
7      configs: [CreateDefaultsConfig!]
8      optionalFields: [String!]
9      first: Int
10      after: String
11   ): CreateDefaultsConnection
12}
13
14input CreateDefaultsConfig {
15   recordTypeId: ID!
16   formFactor = "LARGE": FormFactor
17}

The recordCreateDefaults type has these arguments.

  • objectApiName - The object API name of a supported object. 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 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 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 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 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.

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.

CreateDefaultsConnection Type
1type CreateDefaultsConnection {
2  edges: [CreateDefaultsEdge]
3  pageInfo: PageInfo!
4  totalCount: Int
5}

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.

CreateDefaultsEdge Type
1type CreateDefaultsEdge {
2  node: CreateDefaults
3  cursor: String!
4}

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.

CreateDefaults Type
1type CreateDefaults {
2  recordTypeId: ID
3  formFactor: FormFactor
4  fields: [FieldDefault!]!
5}

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 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.

FieldDefault Type
1type FieldDefault {
2  apiName: String!
3  rawValue: String
4  value: FieldDefaultValue
5}

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 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.

FieldDefaultValue Union
1union FieldDefaultValue =
2    StringValue
3    IntValue
4    BooleanValue
5    IDValue
6    DateValue
7    DateTimeValue
8    TimeValue
9    TextAreaValue
10    LongTextAreaValue
11    RichTextAreaValue
12    PhoneNumberValue
13    EmailValue
14    UrlValue
15    EncryptedStringValue
16    CurrencyValue
17    LongitudeValue
18    LatitudeValue
19    PicklistValue
20    MultiPicklistValue
21    LongValue
22    DoubleValue
23    PercentValue
24    Base64Value
25    JSONValue
26    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 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.

FieldDefaultReferenceValue Type
1type FieldDefaultReferenceValue {
2  id: ID
3  displayValue: String
4  objectApiName: String
5}

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.

Enumeration Types 

The recordCreateDefaults type has these enumerations.

CreateDefaultsMode 

The CreateDefaultsMode enumeration controls which fields are returned.

CreateDefaultsMode Enum
1enum CreateDefaultsMode {
2  LAYOUT
3  TEMPLATE
4}
  • 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.

See Also 

Get Record Create Defaults Examples