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