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 by using this schema.

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.

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.

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.

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

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.

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

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.

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

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.

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

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.

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

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.

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.

The recordCreateDefaults type has these enumerations.

The CreateDefaultsMode enumeration controls which fields are returned.

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

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.

Get Record Create Defaults Examples