CompactLayout defines the key record fields shown at a glance in the Salesforce mobile app, Lightning Experience, and the Outlook and Gmail integrations. Compact layouts are defined through compactLayouts within custom, standard, or external object metadata.
A layout definition and its assignment are separate configuration. CompactLayout defines the fields and their priority; CustomObject.compactLayoutAssignment selects the object-level layout, and RecordType.compactLayoutAssignment selects a layout for a record type. Deploying the definition alone does not transfer those assignments.
Key Elements
The first three elements belong to CompactLayout. The remaining rows identify the container and assignment elements that commonly affect deployment.
| Element | What the Element Controls |
|---|---|
fullName |
The layout's local API name inside an object's compactLayouts entry. For component retrieval, distinguish this local name from the qualified identifier ObjectApiName.CompactLayoutApiName. |
fields |
The fields assigned to the layout. Repeated entries establish configured priority. Text area, long text area, rich text area, and multi-select picklist fields are not supported. |
label |
The layout's display label. A label is not a substitute for the API name in a retrieval identifier. |
compactLayouts on CustomObject
|
Contains compact layout definitions within custom, standard, or external object metadata. |
compactLayoutAssignment on CustomObject
|
Selects the object's compact layout. The value can be a named layout or SYSTEM. |
compactLayoutAssignment on RecordType
|
Selects a compact layout for a particular record type. This assignment belongs to the record type, not to the layout definition. |
Behavior and Constraints
The order of fields represents the priority configured for those fields. Reordering entries changes that priority; it is not an execution sequence.
Compact layouts support all field types except text area, long text area, rich text area, and multi-select picklist. These exclusions matter both when adding a field to a layout and when changing the type of a field already referenced by one.
An object can contain a named compact layout while its object-level compactLayoutAssignment remains SYSTEM. The presence of a definition therefore does not establish that it is selected. Record-type-specific selections are another separate part of the configuration.
The dependency chain runs from object or record-type assignments to the layout, then from CompactLayout.fields to the selected fields, including custom fields represented by CustomField. Changing the field list and changing an assignment affect different parts of that chain.
Deployment and Retrieval
Compact layout definitions are part of object metadata, but they can be addressed as CompactLayout components in a package.xml manifest, the file that lists metadata to retrieve or deploy. The type supports the wildcard * in the manifest. See the CompactLayout Metadata API reference.
For a specific component, community retrieval reports use ObjectApiName.CompactLayoutApiName, with a period between the two API names. For example, Account.Mobile_Account_Layout is a qualified component identifier. Inside the object's compactLayouts entry, the corresponding fullName is only Mobile_Account_Layout. Use API names rather than display labels, and a period rather than a hyphen.
To transfer a selection, include the metadata that owns the relevant compactLayoutAssignment: the object-level assignment on CustomObject or the record-type-specific assignment on RecordType. If the layout exists in the destination but the expected selection is missing, inspect those assignments rather than only the layout definition.
A retrieved assignment without its referenced layout can lead to a deployment failure because the layout cannot be found. That does not necessarily mean the layout was absent from the source org. In a reported CLI case, a .forceignore rule excluded the layout definition during retrieval and deployment while leaving the assignment present.
Deletion failures need a separate diagnosis. Failed destructive deployments using an unqualified name or a hyphen-separated identifier do not establish that Metadata API deletion is unsupported. The reported suggestion that deletion requires interactive replacement assignments remains unverified; that discussion did not show a deletion result using a correctly qualified identifier.
Relationships
Assignments point to a compact layout, and the layout points to its selected fields. The enclosing object's compactLayouts element contains definitions; it is distinct from the assignment elements that select a definition for use.
References
-
CustomField:fields.
Referenced By
-
CustomObject:compactLayoutAssignment. -
RecordType:compactLayoutAssignment.
Reported Issues
-
A retrieval can return no result when the identifier uses labels and a hyphen. In a 2020 CLI discussion, an accepted answer addressed this by using API names in the format
ObjectApiName.CompactLayoutApiName. Retrieval identifier discussion. -
A successful layout deployment can leave assignments unchanged. In a 2021 report, deploying the compact layout did not transfer its selection. The accepted answer located the record-type assignment in the object's
recordTypesmetadata undercompactLayoutAssignmentand advised including the owning object metadata. Assignment deployment discussion. -
CLI deployment preview can misidentify compact layout metadata when the object directory structure is wrong. In an April 2023 report, compact layouts and custom fields appeared as email service metadata. The author reported that moving the object metadata into folders named
objectsresolved the type recognition problem. Source directory diagnosis. -
A missing retrieved definition can cause a later scratch-org deployment to fail. In November 2023, an author found that the object retained its
compactLayoutAssignmentbut the referenced layout definition was missing. The author traced the omission to a**layoutsentry in.forceignore, which excluded layouts during retrieval and deployment. Ignored layout diagnosis. - Reported deletion failures do not confirm a platform prohibition on deleting compact layouts through Metadata API. In November 2023, the posted destructive-deployment attempts used an unqualified name and a hyphen-separated name. An unaccepted answer attributed the failure to replacement-assignment requirements, but no correctly qualified deletion result was shown. Treat that explanation as unverified, not as a confirmed deletion restriction. Deletion discussion.
Common Questions
What name do I use to retrieve a CompactLayout?
Community retrieval reports use ObjectApiName.CompactLayoutApiName, such as Account.Mobile_Account_Layout. Use API names and a period, not display labels and a hyphen. The fullName inside an object's compactLayouts entry is the local layout API name.
Why did my compact layout deploy without its assignment?
The definition does not contain the assignment. Object-level selection belongs to CustomObject.compactLayoutAssignment, and record-type-specific selection belongs to RecordType.compactLayoutAssignment. Include the relevant assignment metadata to transfer the selection.
Which field types cannot be used in a compact layout?
Text area, long text area, rich text area, and multi-select picklist fields are excluded. The order of supported fields in fields establishes their configured priority.
Why is my compact layout missing after retrieval?
Check both the qualified component identifier and client-side exclusions. A November 2023 report traced a missing definition to a **layouts rule in .forceignore, even though the object's assignment remained in the retrieved metadata.
Can a failed destructive deployment prove CompactLayout deletion is unsupported?
No. The reported failure used unqualified and hyphen-separated identifiers, and the discussion showed no correctly qualified deletion result. Its proposed replacement-assignment restriction remains an unverified community explanation.