Get Object Layouts Examples

AVAILABLE API VERSION
API v66.0 and later

Get Object Layout

This example gets the layout for the account object.

{
  uiapi {
    recordLayouts(objectApiName: "Account") {
      edges {
        node {
          id
          layoutType
          mode
          objectApiName
          recordTypeId
          sections {
            heading
            columns
            rows
            collapsible
            layoutRows {
              layoutItems {
                label
                required
                editableForNew
                editableForUpdate
                uiBehavior
                layoutComponents {
                  apiName
                  componentType
                }
              }
            }
          }
        }
      }
      pageInfo {
        hasNextPage
        endCursor
      }
      totalCount
    }
  }
}

Get Object Layout with a Record Type and Mode

This example gets the layout for the opportunity object with a record type and a mode.

{
  uiapi {
    recordLayouts(
      objectApiName: "Opportunity"
      recordTypeIds: ["012000000000000AAA"]
      mode: EDIT
      layoutType: FULL
      formFactor: LARGE
    ) {
      edges {
        node {
          id
          mode
          sections {
            heading
            layoutRows {
              layoutItems {
                label
                required
                layoutComponents {
                  apiName
                  componentType
                }
              }
            }
          }
          saveOptions {
            name
            label
            defaultValue
            isDisplayed
          }
        }
      }
    }
  }
}

Get Object Layout with Record Type Overrides

This example gets the case layout with per-record-type mode and form factor overrides.

{
  uiapi {
    recordLayouts(
      objectApiName: "Case"
      layoutConfigs: [
        { recordTypeId: "012000000000001AAA", mode: EDIT, formFactor: LARGE }
        { recordTypeId: "012000000000002AAA", mode: VIEW, formFactor: SMALL }
      ]
    ) {
      edges {
        node {
          recordTypeId
          mode
          sections {
            heading
            layoutRows {
              layoutItems {
                label
                layoutComponents {
                  apiName
                  componentType
                }
              }
            }
          }
        }
      }
    }
  }
}

Get Object Layout with Pagination

This example gets the account layout with pagination.

{
  uiapi {
    recordLayouts(objectApiName: "Account", first: 5) {
      edges {
        node { id recordTypeId }
        cursor
      }
      pageInfo {
        hasNextPage
        endCursor
      }
      totalCount
    }
  }
}

This example gets the next page.

{
  uiapi {
    recordLayouts(objectApiName: "Account", first: 5, after: "<endCursor>") {
      edges {
        node { id recordTypeId }
        cursor
      }
      pageInfo {
        hasNextPage
        endCursor
      }
    }
  }
}

Get Object Layout with Polymorphic Components

This example gets the account layout with polymorphic components with inline fragments.

{
  uiapi {
    recordLayouts(objectApiName: "Account") {
      edges {
        node {
          sections {
            layoutRows {
              layoutItems {
                label
                layoutComponents {
                  apiName
                  componentType
                  ... on FieldLayoutComponent {
                    label
                  }
                  ... on VisualforceLayoutComponent {
                    visualforceUrl
                    height
                    width
                    showLabel
                    showScroll
                  }
                  ... on CanvasLayoutComponent {
                    referenceId
                    displayLocation
                    height
                    width
                  }
                  ... on CustomLinkLayoutComponent {
                    customLinkUrl
                    label
                    behavior
                  }
                  ... on ReportLayoutComponent {
                    reportId
                    filter
                    size
                    showTitle
                    hideOnError
                    cacheData
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

See Also

Get Object Layouts