platform-flexipage-generate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWhen 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/flexipagesCRITICAL: If the command fails, STOP.
sf template generate flexipage- Install the templates plugin:
bash
sf plugins install templates - Retry the command
sf template generate flexipage - 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- 安装模板插件:
bash
sf plugins install templates - 重试命令
sf template generate flexipage - 验证FlexiPage XML文件是否已创建
在模板命令执行成功前,请勿进入步骤2。生成的XML是整个流程的必要前提。
Template-specific requirements
模板特定要求
RecordPage:
- Requires (e.g., Account, Custom_Object__c)
--sobject - Requires field parameters:
- : Most important identifying field (e.g., Name)
--primary-field - : Record summary (recommended 4-6, max 12)
--secondary-fields - : Full record details, including required fields (e.g., Name)
--detail-fields
AppPage:
- No additional requirements
HomePage:
- No additional requirements
RecordPage:
- 必须指定(例如:Account、Custom_Object__c)
--sobject - 必须指定字段参数:
- :最重要的标识字段(例如:Name)
--primary-field - :记录摘要(建议4-6个,最多12个)
--secondary-fields - :完整记录详情,包括必填字段(例如:Name)
--detail-fields
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 (not
Name/FirstName),LastName(notBillingAddress/BillingStreet/BillingCity),BillingState, etc. when availableMailingAddress - Include required fields in detail-fields: Always include object required fields (like ) in the
Nameparameter, even if they're also used in--detail-fieldsor--primary-field--secondary-fields
- 验证字段存在性:在命令中指定字段前,使用MCP工具或describe命令查询对象的可用字段
- 优先使用复合字段:若存在复合字段,优先使用(而非
Name/FirstName)、LastName(而非BillingAddress/BillingStreet/BillingCity)、BillingState等MailingAddress - 在detail-fields中包含必填字段:始终将对象必填字段(如)包含在
Name参数中,即使它们已在--detail-fields或--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
- 预配置的区域与基础组件
- 正确的字段引用和结构
- 可直接部署或进一步增强
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 --jsonCritical: 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. & → & (FIRST! Encode this before others)
2. < → <
3. > → >
4. " → "
5. ' → 'Wrong:
xml
<value><b>Important</b> text</value>Correct:
xml
<value><b>Important</b> text</value>Check your XML: Search for tags - they should never contain raw or characters.
<value><>任何包含HTML/XML字符的属性值必须按以下顺序手动编码(顺序错误会导致双重编码损坏):
1. & → & (首先处理!先于其他字符编码)
2. < → <
3. > → >
4. " → "
5. ' → '错误示例:
xml
<value><b>Important</b> text</value>正确示例:
xml
<value><b>Important</b> text</value>检查XML: 搜索标签——它们不应包含原始的或字符。
<value><>2. Field References
2. 字段引用
ALWAYS:
NEVER:
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 → . If it's a component slot → .
RegionFacet模板区域(header、main、sidebar):
xml
<name>header</name>
<type>Region</type>组件Facet(如fieldSection列等内部插槽):
xml
<name>Facet-12345</name>
<type>Facet</type>规则: 如果是模板区域名称→;如果是组件插槽→。
RegionFacet4. 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 wrapper
<itemInstances> - Must have with
fieldInstancePropertiesuiBehavior - Use format
Record.{Field}
每个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> - 必须包含带有的
uiBehaviorfieldInstanceProperties - 使用格式
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 blocks with the same
<flexiPageRegions><name> - ✅ If multiple components belong to same facet, combine them in ONE region with multiple
<itemInstances> - ❌ NEVER reuse the same value
<identifier> - ✅ 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., vs
detailTabContent)relatedTabContent
整个FlexiPage文件中的每个标识符和区域/Facet名称必须唯一。
关键规则:
- ❌ 切勿创建两个块使用相同的
<flexiPageRegions><name> - ✅ 如果多个组件属于同一个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>合并与拆分的场景:
- 合并:逻辑上属于同一标签/区域的组件(例如:详情标签中的多个字段区域)
- 拆分:属于不同标签/区域的组件(例如:与
detailTabContent)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 instead of
Fix: Change to
ObjectName.FieldRecord.FieldFix: Change to
Record.{FieldApiName}原因: 使用了格式而非
解决方法: 修改为格式
ObjectName.FieldRecord.Field解决方法: 修改为
Record.{FieldApiName}"Element fieldInstance is duplicated"
"fieldInstance元素重复"
Cause: Multiple fieldInstances in one itemInstances
Fix: Each fieldInstance needs its own wrapper
Fix: Each fieldInstance needs its own
<itemInstances>原因: 一个itemInstances中包含多个fieldInstance
解决方法: 每个fieldInstance都需要单独的包裹
解决方法: 每个fieldInstance都需要单独的
<itemInstances>"Missing fieldInstanceProperties"
"缺少fieldInstanceProperties"
Cause: No uiBehavior specified
Fix: Add with
Fix: Add
fieldInstancePropertiesuiBehavior原因: 未指定uiBehavior
解决方法: 添加带有的
解决方法: 添加带有
uiBehaviorfieldInstanceProperties"Unused Facet"
"未使用的Facet"
Cause: Facet defined but not referenced by any component
Fix: Remove Facet or reference it in a component property
Fix: Remove Facet or reference it in a component property
原因: 定义了Facet但未被任何组件引用
解决方法: 删除Facet或在组件属性中引用它
解决方法: 删除Facet或在组件属性中引用它
"XML parsing error"
"XML解析错误"
Cause: Unencoded HTML/XML in property values
Fix: Manually encode, , , , in all tags
Fix: Manually encode
<>&"'<value>原因: 属性值中包含未编码的HTML/XML
解决方法: 手动对所有标签中的、、、、进行编码
解决方法: 手动对所有
<value><>&"'"Cannot create component with namespace"
"无法创建带命名空间的组件"
Cause: Invalid page name (don't use suffix in page names)
Fix: Use "Volunteer_Record_Page" not "Volunteer__c_Record_Page"
__cFix: Use "Volunteer_Record_Page" not "Volunteer__c_Record_Page"
原因: 页面名称无效(页面名称中请勿使用后缀)
解决方法: 使用"Volunteer_Record_Page"而非"Volunteer__c_Record_Page"
__c解决方法: 使用"Volunteer_Record_Page"而非"Volunteer__c_Record_Page"
"Region specifies mode that parent doesn't support"
"区域指定了父级不支持的模式"
Cause: Added tag to region
Fix: Remove tags - they're not needed for standard regions
<mode><mode>原因: 向区域添加了标签
解决方法: 删除标签——标准区域不需要此标签
<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 availableExamples:
- 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:
-
Named facets (for major content areas):
- (detail tab content)
detailTabContent - (main tab container)
maintabs - (sidebar tab container)
sidebartabs - Use when facet represents meaningful content area
-
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
- Format:
When adding components to existing files:
- Check if target facet name already exists
- If exists: Add new to that existing region (see section 5 above for details)
<itemInstances> - 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命名——两种模式:
-
命名facet(用于主要内容区域):
- (详情标签内容)
detailTabContent - (主标签容器)
maintabs - (侧边栏标签容器)
sidebartabs - 适用于代表有意义内容区域的facet
-
UUID facet(用于内部结构):
- 格式:
Facet-{8hex}-{4hex}-{4hex}-{4hex}-{12hex} - 示例:
Facet-66d5a4b3-bf14-4665-ba75-1ceaa71b2cde - 适用于字段区域列、嵌套容器、匿名插槽
- 格式:
向现有文件添加组件时:
- 检查目标facet名称是否已存在
- 如果存在:将新的添加到该现有区域中(详情参考第5节)
<itemInstances> - 如果不存在:创建带有唯一名称的新区域
Region Selection
区域选择
Parse regions from file - don't hardcode names. Templates vary:
- →
flexipage:recordHomeTemplateDesktop,header,mainsidebar - →
runtime_service_fieldservice:...,header,mainfooter - 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、mainsidebar - →
runtime_service_fieldservice:...、header、mainfooter - 其他模板可能有不同的区域名称
默认放置位置: 目标区域的末尾(最后一个之后)
<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 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.
headerbash
--primary-field Name
--secondary-fields Phone,Industry,AnnualRevenueCLI generates Facets with field references automatically.
位置: 必须位于区域。
显式字段(通过CLI):使用最重要的字段展示记录摘要。单个主字段用于标识记录(如名称)。次要字段(最多12个,建议6个)用于展示记录摘要。
headerbash
--primary-field Name
--secondary-fields Phone,Industry,AnnualRevenueCLI会自动生成带有字段引用的Facet。
fieldSection
fieldSection
Use for: Displaying fields in columns.
Structure: Three-level nesting:
- Template Region (Region type)
- Column Facets (Facet type)
- Field Facets (Facet type) Referenced in component property:
xml
<componentInstanceProperties>
<name>columns</name>
<value>Facet-{uuid}</value>
</componentInstanceProperties>用途: 按列展示字段。
结构: 三级嵌套:
- 模板区域(Region类型)
- 列Facet(Facet类型)
- 字段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):
- 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):
- 带有直接属性的组件实例(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:
- - requires
RecordPage<sobjectType> - - no sobjectType
AppPage - - no sobjectType
HomePage
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> - - 无需sobjectType
AppPage - - 无需sobjectType
HomePage
Validation Checklist
验证清单
Before deploying:
- [NEW PAGES ONLY] Used CLI to bootstrap - NEVER create FlexiPage XML from scratch
- ALL identifiers are unique - no duplicate values anywhere in file
<identifier> - ALL region/facet names are unique - no duplicate values in
<name><flexiPageRegions> - Multiple components in same facet are combined - ONE region with multiple , NOT separate regions with same name
<itemInstances> - All field references use format
Record.{Field} - Each fieldInstance has with
fieldInstancePropertiesuiBehavior - Each fieldInstance in own wrapper
<itemInstances> - Template regions use
<type>Region</type> - Component facets use
<type>Facet</type> - Property values with HTML/XML are manually encoded
- No tags in regions
<mode> - No suffix in page names
__c - Each Facet referenced by exactly one component property
部署前检查:
- [仅新页面] 使用CLI初始化——切勿从零开始创建FlexiPage XML
- 所有标识符唯一——文件中无重复的值
<identifier> - 所有区域/facet名称唯一——中无重复的
<flexiPageRegions>值<name> - 同一facet中的多个组件已合并——一个区域包含多个,而非多个同名区域
<itemInstances> - 所有字段引用使用格式
Record.{Field} - 每个fieldInstance都有带的
uiBehaviorfieldInstanceProperties - 每个fieldInstance都在单独的中
<itemInstances> - 模板区域使用
<type>Region</type> - 组件facet使用
<type>Facet</type> - 包含HTML/XML的属性值已手动编码
- 区域中无标签
<mode> - 页面名称无后缀
__c - 每个Facet仅被一个组件属性引用
Quick Reference: CLI Command
快速参考:CLI命令
bash
undefinedbash
undefinedRecordPage 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
--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
--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"
--name Sales_Dashboard
--template AppPage
--label "Sales Dashboard"
sf template generate flexipage
--name Sales_Dashboard
--template AppPage
--label "Sales Dashboard"
--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"
--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"
--name Custom_Home
--template HomePage
--description "Custom home for sales team"
**所有模板支持:**
- `--output-dir`(默认:当前目录)
- `--api-version`(默认:最新版本)
- `--label`(默认:页面名称)
- `--description`