generating-flexipage

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

When to Use This Skill

何时使用此技能

Use this skill when you need to:
  • Create Lightning pages (RecordPage, AppPage, HomePage)
  • Generate FlexiPage metadata XML
  • Add components to existing FlexiPages
  • Troubleshoot FlexiPage deployment errors
  • Understand FlexiPage structure and component configuration
  • Work with page layouts or Lightning page customization
  • Edit or update ANY *.flexipage-meta.xml file
当你需要以下操作时,请使用此技能:
  • 创建Lightning页面(RecordPage、AppPage、HomePage)
  • 生成FlexiPage元数据XML
  • 向现有FlexiPages添加组件
  • 排查FlexiPage部署错误
  • 理解FlexiPage结构和组件配置
  • 处理页面布局或Lightning页面自定义
  • 编辑或更新任何*.flexipage-meta.xml文件

Specification

规范

FlexiPage Generation Guide

FlexiPage生成指南

Overview

概述

CRITICAL: When creating NEW FlexiPages, you MUST ALWAYS start with the CLI template command. Never create FlexiPage XML from scratch - the CLI provides valid structure, proper regions, and correct component configuration that prevents deployment errors.
Generate Lightning pages (RecordPage, AppPage, HomePage) using CLI bootstrapping for component discovery and configuration.

重要提示:创建新FlexiPage时,必须始终从CLI模板命令开始。 切勿从头创建FlexiPage XML——CLI提供了有效的结构、正确的区域和组件配置,可避免部署错误。
使用CLI引导功能生成Lightning页面(RecordPage、AppPage、HomePage),以进行组件发现和配置。

Quick Start Workflow

快速开始流程

Step 1: Bootstrap with CLI

步骤1:使用CLI引导

MANDATORY FOR NEW PAGES: This step is NOT optional. Always use the CLI template command when creating a new FlexiPage. The CLI generates valid XML structure, proper regions, and correct metadata that prevents common deployment errors. Only skip this step if you're editing an existing FlexiPage file.
bash
sf template generate flexipage \
  --name <PageName> \
  --template <RecordPage|AppPage|HomePage> \
  --sobject <SObject> \
  --primary-field <Field1> \
  --secondary-fields <Field2,Field3> \
  --detail-fields <Field4,Field5,Field6,Field7> \
  --output-dir force-app/main/default/flexipages
CRITICAL: If the
sf template generate flexipage
command fails, STOP.
  1. Install the templates plugin:
    bash
    sf plugins install templates
  2. Retry the
    sf template generate flexipage
    command
  3. Verify the FlexiPage XML file was created
Do NOT continue to Step 2 until the template command succeeds. The generated XML is required for the entire workflow.
新页面必填:此步骤不可省略。 创建新FlexiPage时,务必使用CLI模板命令。CLI生成有效的XML结构、正确的区域和元数据,可避免常见的部署错误。仅当你编辑现有FlexiPage文件时,才可跳过此步骤。
bash
sf template generate flexipage \\
  --name <PageName> \\
  --template <RecordPage|AppPage|HomePage> \\
  --sobject <SObject> \\
  --primary-field <Field1> \\
  --secondary-fields <Field2,Field3> \\
  --detail-fields <Field4,Field5,Field6,Field7> \\
  --output-dir force-app/main/default/flexipages
重要提示: 如果
sf template generate flexipage
命令失败,请立即停止
  1. 安装模板插件:
    bash
    sf plugins install templates
  2. 重试
    sf template generate flexipage
    命令
  3. 验证FlexiPage XML文件已创建
在模板命令成功之前,请勿继续步骤2。生成的XML是整个流程的必需文件。

Template-specific requirements

模板特定要求

RecordPage:
  • Requires
    --sobject
    (e.g., Account, Custom_Object__c)
  • Requires field parameters:
    • --primary-field
      : Most important identifying field (e.g., Name)
    • --secondary-fields
      : Record summary (recommended 4-6, max 12)
    • --detail-fields
      : Full record details, including required fields (e.g., Name)
AppPage:
  • No additional requirements
HomePage:
  • No additional requirements
RecordPage:
  • 必须指定
    --sobject
    (例如Account、Custom_Object__c)
  • 必须指定字段参数:
    • --primary-field
      :最重要的标识字段(例如Name)
    • --secondary-fields
      :记录摘要(建议4-6个,最多12个)
    • --detail-fields
      :完整记录详情,包括必填字段(例如Name)
AppPage:
  • 无额外要求
HomePage:
  • 无额外要求

Field Selection Rules

字段选择规则

  • Validate fields exist: Use MCP tools or describe commands to discover available fields for the object before specifying them in the command
  • Prefer compound fields: Use
    Name
    (not
    FirstName
    /
    LastName
    ),
    BillingAddress
    (not
    BillingStreet
    /
    BillingCity
    /
    BillingState
    ),
    MailingAddress
    , etc. when available
  • Include required fields in detail-fields: Always include object required fields (like
    Name
    ) in the
    --detail-fields
    parameter, even if they're also used in
    --primary-field
    or
    --secondary-fields
  • 验证字段存在: 在命令中指定字段之前,使用MCP工具或describe命令发现对象的可用字段
  • 优先使用复合字段: 如有可用,使用
    Name
    (而非
    FirstName
    /
    LastName
    )、
    BillingAddress
    (而非
    BillingStreet
    /
    BillingCity
    /
    BillingState
    )、
    MailingAddress
  • 在detail-fields中包含必填字段: 始终在
    --detail-fields
    参数中包含对象必填字段(如
    Name
    ),即使它们已在
    --primary-field
    --secondary-fields
    中使用

What you get

你将获得

  • Valid FlexiPage XML with correct structure
  • Pre-configured regions and basic components
  • Proper field references and facet structure
  • Ready to deploy as-is or enhance further
  • 具有正确结构的有效FlexiPage XML
  • 预配置的区域和基础组件
  • 正确的字段引用和facet结构
  • 可直接部署或进一步增强

Step 2: Deploy Base Page

步骤2:部署基础页面

Run a dry-run deployment of the entire project to validate the page and dependencies:
bash
sf project deploy start --dry-run -d "force-app/main/default" --test-level NoTestRun --wait 10 --json
Critical: Fix any deployment errors before proceeding. The page must validate successfully.
运行项目的试运行部署,以验证页面和依赖项:
bash
sf project deploy start --dry-run -d "force-app/main/default" --test-level NoTestRun --wait 10 --json
重要提示: 在继续之前修复所有部署错误。页面必须验证成功。

Step 3: STOP - No Further Modifications

步骤3:停止 - 无需进一步修改

MANDATORY: Stop after Step 2. Do not add components or edit the FlexiPage XML.
This applies even if the user requested:
  • Additional components
  • Page customization
  • Component configuration
What you CAN do:
  • Suggest what components would be useful
  • Explain what enhancements are possible
  • Document what would need to be added manually
What you CANNOT do:
  • Modify the XML file
  • Add any components
  • Make any enhancements

强制要求:完成步骤2后停止。请勿添加组件或编辑FlexiPage XML。
即使用户要求以下操作,此规则也适用:
  • 添加额外组件
  • 页面自定义
  • 组件配置
你可以做的:
  • 建议哪些组件有用
  • 解释可以进行哪些增强
  • 记录需要手动添加的内容
你不可以做的:
  • 修改XML文件
  • 添加任何组件
  • 进行任何增强

Critical XML Rules

关键XML规则

1. Property Value Encoding (MOST COMMON ERROR)

1. 属性值编码(最常见错误)

Any property value with HTML/XML characters MUST be manually encoded in the following order (wrong order causes double-encoding corruption):
1. & → &amp;   (FIRST! Encode this before others)
2. < → &lt;
3. > → &gt;
4. " → &quot;
5. ' → &apos;
Wrong:
xml
<value><b>Important</b> text</value>
Correct:
xml
<value>&lt;b&gt;Important&lt;/b&gt; text</value>
Check your XML: Search for
<value>
tags - they should never contain raw
<
or
>
characters.
任何包含HTML/XML字符的属性值必须按以下顺序手动编码(错误顺序会导致双重编码损坏):
1. & → &amp;   (首先处理!先编码此字符,再处理其他)
2. < → &lt;
3. > → &gt;
4. " → &quot;
5. ' → &apos;
错误示例:
xml
<value><b>Important</b> text</value>
正确示例:
xml
<value>&lt;b&gt;Important&lt;/b&gt; text</value>
检查你的XML: 搜索
<value>
标签——它们绝不能包含原始的
<
>
字符。

2. Field References

2. 字段引用

ALWAYS:
Record.{FieldApiName}

NEVER:
{ObjectName}.{FieldApiName}
xml
<!-- Correct -->
<fieldItem>Record.Name</fieldItem>

        <!-- Wrong -->
<fieldItem>Account.Name</fieldItem>
必须使用:
Record.{FieldApiName}

禁止使用:
{ObjectName}.{FieldApiName}
xml
<!-- 正确 -->
<fieldItem>Record.Name</fieldItem>

        <!-- 错误 -->
<fieldItem>Account.Name</fieldItem>

3. Region vs Facet Types

3. Region与Facet类型

Template Regions (header, main, sidebar):
xml
<name>header</name>
<type>Region</type>
Component Facets (internal slots like fieldSection columns):
xml
<name>Facet-12345</name>
<type>Facet</type>
Rule: If it's a template region name →
Region
. If it's a component slot →
Facet
.
模板区域(header、main、sidebar):
xml
<name>header</name>
<type>Region</type>
组件Facet(内部插槽,如fieldSection列):
xml
<name>Facet-12345</name>
<type>Facet</type>
规则: 如果是模板区域名称→
Region
。如果是组件插槽→
Facet

4. fieldInstance Structure

4. fieldInstance结构

Every fieldInstance requires:
xml
<itemInstances>
   <fieldInstance>
      <fieldInstanceProperties>
         <name>uiBehavior</name>
         <value>none</value> <!-- none|readonly|required -->
      </fieldInstanceProperties>
      <fieldItem>Record.FieldName__c</fieldItem>
      <identifier>RecordFieldName_cField</identifier>
   </fieldInstance>
</itemInstances>
Rules:
  • Each fieldInstance in its own
    <itemInstances>
    wrapper
  • Must have
    fieldInstanceProperties
    with
    uiBehavior
  • Use
    Record.{Field}
    format
每个fieldInstance需要:
xml
<itemInstances>
   <fieldInstance>
      <fieldInstanceProperties>
         <name>uiBehavior</name>
         <value>none</value> <!-- none|readonly|required -->
      </fieldInstanceProperties>
      <fieldItem>Record.FieldName__c</fieldItem>
      <identifier>RecordFieldName_cField</identifier>
   </fieldInstance>
</itemInstances>
规则:
  • 每个fieldInstance都在自己的
    <itemInstances>
    包装器中
  • 必须包含带有
    uiBehavior
    fieldInstanceProperties
  • 使用
    Record.{Field}
    格式

5. Unique Identifiers and Region Names (CRITICAL - PREVENTS DUPLICATE ERRORS)

5. 唯一标识符和区域名称(关键 - 防止重复错误)

EVERY identifier and region/facet name MUST be unique across the entire FlexiPage file.
Critical Rules:
  • NEVER create two
    <flexiPageRegions>
    blocks with the same
    <name>
  • If multiple components belong to same facet, combine them in ONE region with multiple
    <itemInstances>
  • NEVER reuse the same
    <identifier>
    value
  • Always read entire file first and extract ALL existing identifiers and names
Wrong - This WILL FAIL with duplicate name error:
xml
<!-- First field section in detail tab -->
<flexiPageRegions>
   <itemInstances>
      <componentInstance>
         <identifier>flexipage_property_details_fieldSection</identifier>
         ...
      </componentInstance>
   </itemInstances>
   <name>detailTabContent</name>  <!-- ❌ DUPLICATE NAME -->
   <type>Facet</type>
</flexiPageRegions>

<!-- Second field section in detail tab -->
<flexiPageRegions>
   <itemInstances>
      <componentInstance>
         <identifier>flexipage_pricing_fieldSection</identifier>
         ...
      </componentInstance>
   </itemInstances>
   <name>detailTabContent</name>  <!-- ❌ DUPLICATE NAME - DEPLOYMENT FAILS -->
   <type>Facet</type>
</flexiPageRegions>
Correct - Combine itemInstances in ONE region:
xml
<!-- Both field sections in same detail tab facet -->
<flexiPageRegions>
   <itemInstances>
      <componentInstance>
         <identifier>flexipage_property_details_fieldSection</identifier>
         ...
      </componentInstance>
   </itemInstances>
   <itemInstances>
      <componentInstance>
         <identifier>flexipage_pricing_fieldSection</identifier>
         ...
      </componentInstance>
   </itemInstances>
   <name>detailTabContent</name>  <!-- ✅ ONE REGION, MULTIPLE COMPONENTS -->
   <type>Facet</type>
</flexiPageRegions>
When to combine vs separate:
  • Combine: Components that logically belong to same tab/section (e.g., multiple field sections in detail tab)
  • Separate: Components that belong to different tabs/sections (e.g.,
    detailTabContent
    vs
    relatedTabContent
    )

整个FlexiPage文件中的每个标识符和区域/facet名称必须唯一。
关键规则:
  • 绝不能创建两个具有相同
    <name>
    <flexiPageRegions>
  • 如果多个组件属于同一个facet,将它们合并到一个包含多个
    <itemInstances>
    的区域中
  • 绝不能重复使用相同的
    <identifier>
  • 始终先读取整个文件,提取所有现有标识符和名称
错误示例 - 会因重复名称错误失败:
xml
<!-- 详情标签中的第一个字段部分 -->
<flexiPageRegions>
   <itemInstances>
      <componentInstance>
         <identifier>flexipage_property_details_fieldSection</identifier>
         ...
      </componentInstance>
   </itemInstances>
   <name>detailTabContent</name>  <!-- ❌ 重复名称 -->
   <type>Facet</type>
</flexiPageRegions>

<!-- 详情标签中的第二个字段部分 -->
<flexiPageRegions>
   <itemInstances>
      <componentInstance>
         <identifier>flexipage_pricing_fieldSection</identifier>
         ...
      </componentInstance>
   </itemInstances>
   <name>detailTabContent</name>  <!-- ❌ 重复名称 - 部署失败 -->
   <type>Facet</type>
</flexiPageRegions>
正确示例 - 将itemInstances合并到一个区域中:
xml
<!-- 同一个详情标签facet中的两个字段部分 -->
<flexiPageRegions>
   <itemInstances>
      <componentInstance>
         <identifier>flexipage_property_details_fieldSection</identifier>
         ...
      </componentInstance>
   </itemInstances>
   <itemInstances>
      <componentInstance>
         <identifier>flexipage_pricing_fieldSection</identifier>
         ...
      </componentInstance>
   </itemInstances>
   <name>detailTabContent</name>  <!-- ✅ 一个区域,多个组件 -->
   <type>Facet</type>
</flexiPageRegions>
何时合并 vs 分开:
  • 合并: 逻辑上属于同一个标签/部分的组件(例如详情标签中的多个字段部分)
  • 分开: 属于不同标签/部分的组件(例如
    detailTabContent
    vs
    relatedTabContent

Common Deployment Errors

常见部署错误

"We couldn't retrieve or load the information on the field"

"无法检索或加载字段信息"

Cause: Invalid field API name - field doesn't exist on the object or has incorrect spelling Fix: Use MCP tools or describe commands to discover valid fields, then update the field reference (see Field Selection Rules)
原因: 无效的字段API名称 - 字段在对象上不存在或拼写错误 修复: 使用MCP工具或describe命令发现有效字段,然后更新字段引用(参见字段选择规则)

"Invalid field reference"

"无效的字段引用"

Cause: Used
ObjectName.Field
instead of
Record.Field

Fix: Change to
Record.{FieldApiName}
原因: 使用了
ObjectName.Field
而非
Record.Field

修复: 改为
Record.{FieldApiName}

"Element fieldInstance is duplicated"

"Element fieldInstance重复"

Cause: Multiple fieldInstances in one itemInstances
Fix: Each fieldInstance needs its own
<itemInstances>
wrapper
原因: 一个itemInstances中有多个fieldInstance
修复: 每个fieldInstance需要自己的
<itemInstances>
包装器

"Missing fieldInstanceProperties"

"缺少fieldInstanceProperties"

Cause: No uiBehavior specified
Fix: Add
fieldInstanceProperties
with
uiBehavior
原因: 未指定uiBehavior
修复: 添加带有
uiBehavior
fieldInstanceProperties

"Unused Facet"

"未使用的Facet"

Cause: Facet defined but not referenced by any component
Fix: Remove Facet or reference it in a component property
原因: 定义了Facet但未被任何组件引用
修复: 删除Facet或在组件属性中引用它

"XML parsing error"

"XML解析错误"

Cause: Unencoded HTML/XML in property values
Fix: Manually encode
<
,
>
,
&
,
"
,
'
in all
<value>
tags
原因: 属性值中存在未编码的HTML/XML
修复: 在所有
<value>
标签中手动编码
<
>
&
"
'

"Cannot create component with namespace"

"无法创建带有命名空间的组件"

Cause: Invalid page name (don't use
__c
suffix in page names)
Fix: Use "Volunteer_Record_Page" not "Volunteer__c_Record_Page"
原因: 无效的页面名称(页面名称中不要使用
__c
后缀)
修复: 使用"Volunteer_Record_Page"而非"Volunteer__c_Record_Page"

"Region specifies mode that parent doesn't support"

"区域指定了父级不支持的模式"

Cause: Added
<mode>
tag to region Fix: Remove
<mode>
tags - they're not needed for standard regions

原因: 向区域添加了
<mode>
标签 修复: 删除
<mode>
标签 - 标准区域不需要它们

Generating Unique Identifiers

生成唯一标识符

CRITICAL: Before generating ANY new identifier or facet name, follow the rules in section 5 of "Critical XML Rules" above.
Identifier Generation Algorithm:
1. Extract ALL existing <identifier> AND <name> values from XML
2. Generate base name: {componentType}_{context}
   Examples: "relatedList_contacts", "richText_header", "tabs_main"
3. Find first available number:
   - Try "{base}_1"
   - If exists, try "{base}_2", "{base}_3", etc.
   - Use first available
Examples:
  • First contacts related list:
    relatedList_contacts_1
  • Second contacts related list:
    relatedList_contacts_2
  • Rich text in header:
    richText_header_1
  • Field section:
    fieldSection_details_1
Facet Naming - Two Patterns:
  1. Named facets (for major content areas):
    • detailTabContent
      (detail tab content)
    • maintabs
      (main tab container)
    • sidebartabs
      (sidebar tab container)
    • Use when facet represents meaningful content area
  2. UUID facets (for internal structure):
    • Format:
      Facet-{8hex}-{4hex}-{4hex}-{4hex}-{12hex}
    • Example:
      Facet-66d5a4b3-bf14-4665-ba75-1ceaa71b2cde
    • Use for field section columns, nested containers, anonymous slots
When adding components to existing files:
  • Check if target facet name already exists
  • If exists: Add new
    <itemInstances>
    to that existing region (see section 5 above for details)
  • If doesn't exist: Create new region with unique name

重要提示:在生成任何新标识符或facet名称之前,请遵循上面“关键XML规则”第5节中的规则。
标识符生成算法:
1. 从XML中提取所有<identifier>和<name>值
2. 生成基础名称:{componentType}_{context}
   示例:"relatedList_contacts", "richText_header", "tabs_main"
3. 找到第一个可用的编号:
   - 尝试"{base}_1"
   - 如果存在,尝试"{base}_2"、"{base}_3"等
   - 使用第一个可用的编号
示例:
  • 第一个联系人相关列表:
    relatedList_contacts_1
  • 第二个联系人相关列表:
    relatedList_contacts_2
  • 页眉中的富文本:
    richText_header_1
  • 字段部分:
    fieldSection_details_1
Facet命名 - 两种模式:
  1. 命名facet(主要内容区域):
    • detailTabContent
      (详情标签内容)
    • maintabs
      (主标签容器)
    • sidebartabs
      (侧边栏标签容器)
    • 当facet代表有意义的内容区域时使用
  2. UUID facet(内部结构):
    • 格式:
      Facet-{8hex}-{4hex}-{4hex}-{4hex}-{12hex}
    • 示例:
      Facet-66d5a4b3-bf14-4665-ba75-1ceaa71b2cde
    • 用于字段部分列、嵌套容器、匿名插槽
向现有文件添加组件时:
  • 检查目标facet名称是否已存在
  • 如果存在:将新的
    <itemInstances>
    添加到该现有区域(详见上面第5节)
  • 如果不存在:创建具有唯一名称的新区域

Region Selection

区域选择

Parse regions from file - don't hardcode names. Templates vary:
  • flexipage:recordHomeTemplateDesktop
    header
    ,
    main
    ,
    sidebar
  • runtime_service_fieldservice:...
    header
    ,
    main
    ,
    footer
  • Others may have different region names
Default placement: End of target region (after last
<itemInstances>
)
Insertion pattern:
xml
<flexiPageRegions>
   <name>main</name>  <!-- or whatever region name exists -->
   <type>Region</type>
   <itemInstances><!-- Existing component 1 --></itemInstances>
   <itemInstances><!-- Existing component 2 --></itemInstances>
   <itemInstances>
      <!-- INSERT NEW COMPONENT HERE -->
   </itemInstances>
</flexiPageRegions>

从文件中解析区域 - 不要硬编码名称。模板各不相同:
  • flexipage:recordHomeTemplateDesktop
    header
    main
    sidebar
  • runtime_service_fieldservice:...
    header
    main
    footer
  • 其他模板可能有不同的区域名称
默认位置: 目标区域的末尾(最后一个
<itemInstances>
之后)
插入模式:
xml
<flexiPageRegions>
   <name>main</name>  <!-- 或任何已存在的区域名称 -->
   <type>Region</type>
   <itemInstances><!-- 现有组件1 --></itemInstances>
   <itemInstances><!-- 现有组件2 --></itemInstances>
   <itemInstances>
      <!-- 在此插入新组件 -->
   </itemInstances>
</flexiPageRegions>

Container Components with Facets

带有Facet的容器组件

Components like tabs, accordions, field sections require facets.
Pattern:
xml
<!-- 1. Component in region -->
<flexiPageRegions>
   <itemInstances>
      <componentInstance>
         <componentName>flexipage:tabset2</componentName>
         <identifier>tabs_main_1</identifier>
         <componentInstanceProperties>
            <name>tabs</name>
            <value>tab1_content</value>
            <value>tab2_content</value>
         </componentInstanceProperties>
      </componentInstance>
   </itemInstances>
   <name>main</name>
   <type>Region</type>
</flexiPageRegions>

        <!-- 2. Facets (siblings of region, NOT nested inside) -->
<flexiPageRegions>
<itemInstances><!-- Tab 1 content --></itemInstances>
<name>tab1_content</name>
<type>Facet</type>
</flexiPageRegions>

<flexiPageRegions>
<itemInstances><!-- Tab 2 content --></itemInstances>
<name>tab2_content</name>
<type>Facet</type>
</flexiPageRegions>

Critical: Facet regions are siblings of template regions at the same level, not nested inside them.

标签、手风琴、字段部分等组件需要facet。
模式:
xml
<!-- 1. 区域中的组件 -->
<flexiPageRegions>
   <itemInstances>
      <componentInstance>
         <componentName>flexipage:tabset2</componentName>
         <identifier>tabs_main_1</identifier>
         <componentInstanceProperties>
            <name>tabs</name>
            <value>tab1_content</value>
            <value>tab2_content</value>
         </componentInstanceProperties>
      </componentInstance>
   </itemInstances>
   <name>main</name>
   <type>Region</type>
</flexiPageRegions>

        <!-- 2. Facet(与区域同级,而非嵌套在内部) -->
<flexiPageRegions>
<itemInstances><!-- 标签1内容 --></itemInstances>
<name>tab1_content</name>
<type>Facet</type>
</flexiPageRegions>

<flexiPageRegions>
<itemInstances><!-- 标签2内容 --></itemInstances>
<name>tab2_content</name>
<type>Facet</type>
</flexiPageRegions>

重要提示: Facet区域与模板区域同级,而非嵌套在模板区域内部。

Component-Specific Tips

组件特定提示

dynamicHighlights (RecordPage Header)

dynamicHighlights(RecordPage页眉)

Location: Must be in
header
region. Explicit Fields (via CLI): Use the most important fields to show a summary of the record. The single primary field is used to identify the record, like a name. The secondary fields (max 12, recommended 6) are used as a summary of the record.
bash
--primary-field Name
--secondary-fields Phone,Industry,AnnualRevenue
CLI generates Facets with field references automatically.
位置: 必须在
header
区域中。 显式字段(通过CLI):使用最重要的字段显示记录摘要。单个主字段用于标识记录,例如名称。次要字段(最多12个,建议6个)用于记录摘要。
bash
--primary-field Name
--secondary-fields Phone,Industry,AnnualRevenue
CLI会自动生成带有字段引用的Facet。

fieldSection

fieldSection

Use for: Displaying fields in columns. Structure: Three-level nesting:
  1. Template Region (Region type)
  2. Column Facets (Facet type)
  3. Field Facets (Facet type) Referenced in component property:
xml
<componentInstanceProperties>
   <name>columns</name>
   <value>Facet-{uuid}</value>
</componentInstanceProperties>
用途: 在列中显示字段。 结构: 三级嵌套:
  1. 模板区域(Region类型)
  2. 列Facet(Facet类型)
  3. 字段Facet(Facet类型) 在组件属性中引用:
xml
<componentInstanceProperties>
   <name>columns</name>
   <value>Facet-{uuid}</value>
</componentInstanceProperties>

rich Text component

富文本组件

Component name: flexipage:richText
Use for: Displaying HTML-formatted rich text content with support for text formatting, headings, lists, tables, images, links, forms, and multimedia elements. Preserves styling and layout. Escape all special characters in the default text.
Location: Can be used in any region on any page type (Home, Record, App, Community pages).
CLI generates the component directly without nested structures.
User: "Add a rich text component to force-app/.../Account_Record_Page.flexipage-meta.xml"
Structure: Single-level component (no facets):
  1. Component instance (flexipage:richText) with direct properties
XML Structure Example:
xml
<itemInstances>
   <componentInstance>
      <componentInstanceProperties>
         <name>decorate</name>
         <value>true</value>
      </componentInstanceProperties>
      <componentName>flexipage:richText</componentName>
      <identifier>flexipage_richText</identifier>
   </componentInstance>
</itemInstances>
Identifier Pattern: flexipage_richText or flexipage_richText_{sequence}

组件名称:flexipage:richText
用途:显示HTML格式的富文本内容,支持文本格式、标题、列表、表格、图片、链接、表单和多媒体元素。保留样式和布局。转义默认文本中的所有特殊字符。
位置:可用于任何页面类型(主页、记录页、应用页、社区页)的任何区域。
CLI直接生成组件,无需嵌套结构。
用户示例:"向force-app/.../Account_Record_Page.flexipage-meta.xml添加一个富文本组件"
结构:单级组件(无facet):
  1. 组件实例(flexipage:richText),带有直接属性
XML结构示例:
xml
<itemInstances>
   <componentInstance>
      <componentInstanceProperties>
         <name>decorate</name>
         <value>true</value>
      </componentInstanceProperties>
      <componentName>flexipage:richText</componentName>
      <identifier>flexipage_richText</identifier>
   </componentInstance>
</itemInstances>
标识符模式:flexipage_richText或flexipage_richText_{sequence}

Required Metadata Structure

必需的元数据结构

xml
<FlexiPage xmlns="http://soap.sforce.com/2006/04/metadata">
   <flexiPageRegions>
      <!-- Regions and components here -->
   </flexiPageRegions>
   <masterLabel>Page Label</masterLabel>
   <template>
      <name>flexipage:recordHomeTemplateDesktop</name>
   </template>
   <type>RecordPage</type>
   <sobjectType>Object__c</sobjectType> <!-- RecordPage only -->
</FlexiPage>
Page Types:
  • RecordPage
    - requires
    <sobjectType>
  • AppPage
    - no sobjectType
  • HomePage
    - no sobjectType

xml
<FlexiPage xmlns="http://soap.sforce.com/2006/04/metadata">
   <flexiPageRegions>
      <!-- 区域和组件在此处 -->
   </flexiPageRegions>
   <masterLabel>Page Label</masterLabel>
   <template>
      <name>flexipage:recordHomeTemplateDesktop</name>
   </template>
   <type>RecordPage</type>
   <sobjectType>Object__c</sobjectType> <!-- 仅RecordPage需要 -->
</FlexiPage>
页面类型:
  • RecordPage
    - 需要
    <sobjectType>
  • AppPage
    - 不需要sobjectType
  • HomePage
    - 不需要sobjectType

Validation Checklist

验证检查清单

Before deploying:
  • [NEW PAGES ONLY] Used CLI to bootstrap - NEVER create FlexiPage XML from scratch
  • ALL identifiers are unique - no duplicate
    <identifier>
    values anywhere in file
  • ALL region/facet names are unique - no duplicate
    <name>
    values in
    <flexiPageRegions>
  • Multiple components in same facet are combined - ONE region with multiple
    <itemInstances>
    , NOT separate regions with same name
  • All field references use
    Record.{Field}
    format
  • Each fieldInstance has
    fieldInstanceProperties
    with
    uiBehavior
  • Each fieldInstance in own
    <itemInstances>
    wrapper
  • Template regions use
    <type>Region</type>
  • Component facets use
    <type>Facet</type>
  • Property values with HTML/XML are manually encoded
  • No
    <mode>
    tags in regions
  • No
    __c
    suffix in page names
  • Each Facet referenced by exactly one component property

部署前:
  • [仅新页面] 使用CLI引导 - 切勿从头创建FlexiPage XML
  • 所有标识符唯一 - 文件中无重复的
    <identifier>
  • 所有区域/facet名称唯一 -
    <flexiPageRegions>
    中无重复的
    <name>
  • 同一facet中的多个组件已合并 - 一个区域包含多个
    <itemInstances>
    ,而非多个同名区域
  • 所有字段引用使用
    Record.{Field}
    格式
  • 每个fieldInstance都有带有
    uiBehavior
    fieldInstanceProperties
  • 每个fieldInstance都在自己的
    <itemInstances>
    包装器中
  • 模板区域使用
    <type>Region</type>
  • 组件facet使用
    <type>Facet</type>
  • 包含HTML/XML的属性值已手动编码
  • 区域中无
    <mode>
    标签
  • 页面名称中无
    __c
    后缀
  • 每个Facet恰好被一个组件属性引用

Quick Reference: CLI Command

快速参考:CLI命令

bash
undefined
bash
undefined

RecordPage with fields

带字段的RecordPage

sf template generate flexipage
--name Account_Custom_Page
--template RecordPage
--sobject Account
--primary-field Name
--secondary-fields Phone,Industry,AnnualRevenue
--detail-fields Street,City,State,Name,Phone,Email
sf template generate flexipage \ --name Account_Custom_Page \ --template RecordPage \ --sobject Account \ --primary-field Name \ --secondary-fields Phone,Industry,AnnualRevenue \ --detail-fields Street,City,State,Name,Phone,Email

AppPage

AppPage

sf template generate flexipage
--name Sales_Dashboard
--template AppPage
--label "Sales Dashboard"
sf template generate flexipage \ --name Sales_Dashboard \ --template AppPage \ --label "Sales Dashboard"

HomePage

HomePage

sf template generate flexipage
--name Custom_Home
--template HomePage
--description "Custom home for sales team"

**All templates support:**
- `--output-dir` (default: current directory)
- `--api-version` (default: latest)
- `--label` (default: page name)
- `--description`
sf template generate flexipage \ --name Custom_Home \ --template HomePage \ --description "Custom home for sales team"

**所有模板支持:**
- `--output-dir`(默认:当前目录)
- `--api-version`(默认:最新版本)
- `--label`(默认:页面名称)
- `--description`
",