platform-report-generate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOverview
概述
Lightning Reports define how Salesforce data is queried, grouped, filtered, and displayed. Each report is a single file placed under within the project's source directory (check → for the source root).
.report-meta.xmlreports/<FolderName>/sfdx-project.jsonpackageDirectories[].pathLightning Reports定义了Salesforce数据的查询、分组、筛选和显示方式。每个报表对应一个单独的文件,存放于项目源目录下的路径中(可查看 → 获取源根目录)。
.report-meta.xmlreports/<FolderName>/sfdx-project.jsonpackageDirectories[].pathCritical Rules (Read First)
关键规则(请先阅读)
TOP DEPLOYMENT KILLERS — check these BEFORE generating any report:
- Grouping fields in columns — Fields in or
<groupingsDown>must NEVER also appear in<groupingsAcross><columns> - Wrong column names — Column names are report-type-specific. ALWAYS call MCP tools to verify (see )
references/column-names.md - Wrong scope — LeadList uses , not
orgorganization - Filter column dot notation — Filter values use FLAT names (
<column>,INDUSTRY) NOT dot notation (TYPEis INVALID)ACCOUNT.INDUSTRY - Multi-value picklist filters — Use ONE with comma-separated
<criteriaItems>(e.g.,<value>). Do NOT split into multiple criteriaItems with booleanFilterTechnology,Financial Services
部署失败头号原因 — 生成任何报表前务必检查以下内容:
- 列中的分组字段 — 或
<groupingsDown>中的字段绝对不能同时出现在<groupingsAcross>中<columns> - 错误的列名 — 列名是特定于报表类型的。务必调用MCP工具进行验证(详见)
references/column-names.md - 错误的作用域 — LeadList使用,而非
orgorganization - 筛选器列的点表示法 — 筛选器值使用扁平名称(如
<column>、INDUSTRY),不使用点表示法(TYPE是无效的)ACCOUNT.INDUSTRY - 多值选择列表筛选器 — 使用一个,其中
<criteriaItems>用逗号分隔(例如<value>)。请勿拆分为多个带booleanFilter的criteriaItemsTechnology,Financial Services
Rule 1: Format Determines Required Elements
规则1:格式决定必填元素
| Format | | | |
|---|---|---|---|
| Not allowed | Not allowed | No |
| At least 1 (max 3) | Not allowed | No |
| At least 1 (max 3) | At least 1 (max 3) | No |
| Not at top level | Not at top level | At least 2 (max 5) |
| 格式 | | | |
|---|---|---|---|
| 不允许 | 不允许 | 无 |
| 至少1个(最多3个) | 不允许 | 无 |
| 至少1个(最多3个) | 至少1个(最多3个) | 无 |
| 不允许在顶层 | 不允许在顶层 | 至少2个(最多5个) |
Rule 2: Use Platform Column Names
规则2:使用平台列名
Report metadata uses platform report column names, NOT raw API field names. ALWAYS call or to confirm valid column names. See for common mappings per report type.
get_metadata_type_sectionsget_metadata_type_contextreferences/column-names.md报表元数据使用平台报表列名,而非原始API字段名。务必调用或确认有效的列名。详见中各报表类型的常见映射关系。
get_metadata_type_sectionsget_metadata_type_contextreferences/column-names.mdRule 3: Valid Report Type Required
规则3:需要有效的报表类型
<reportType>OpportunityAccountListCaseListLeadListAccountContactRole<reportType>OpportunityAccountListCaseListLeadListAccountContactRoleRule 4–5: Chart & Aggregates Require Summary/Matrix
规则4–5:图表与聚合仅支持汇总/矩阵报表
Charts and (Sum, Average, etc.) only work in Summary and Matrix reports.
<aggregateTypes>图表和(求和、平均值等)仅在汇总报表和矩阵报表中生效。
<aggregateTypes>Rule 6–8: Limits
规则6–8:限制条件
- Max 3 cross-filters per report, each with up to 5 criteria items
- must reference all filters sequentially (e.g.,
<filterLogic>)1 AND (2 OR 3) - Joined reports: 2–5 blocks, each block format must be Summary or Matrix (not Tabular)
- 每个报表最多支持3个交叉筛选器,每个筛选器最多包含5个条件项
- 必须按顺序引用所有筛选器(例如
<filterLogic>)1 AND (2 OR 3) - 联合报表:包含2–5个块,每个块的格式必须为汇总或矩阵(不能是表格)
Rule 9: Folder Structure
规则9:文件夹结构
Reports must live inside a folder with a corresponding folder metadata file:
xml
<sourceDir>/reports/<FolderName>/<ReportName>.report-meta.xml
<sourceDir>/reports/<FolderName>-meta.xmlDetermine from (commonly , but this is configurable).
<sourceDir>sfdx-project.jsonforce-app/main/default报表必须存放在包含对应文件夹元数据文件的目录中:
xml
<sourceDir>/reports/<FolderName>/<ReportName>.report-meta.xml
<sourceDir>/reports/<FolderName>-meta.xml从中确定(通常为,但可配置)。
sfdx-project.json<sourceDir>force-app/main/defaultRule 10–11: Date Columns & Scope
规则10–11:日期列与作用域
- Date columns use platform names (, not
CLOSE_DATE)CloseDate - LeadList scope is ; Opportunity/AccountList/CaseList use
orgorganization
- 日期列使用平台名称(,而非
CLOSE_DATE)CloseDate - LeadList的作用域为;Opportunity/AccountList/CaseList使用
orgorganization
Rule 12–13: Description & Groupings
规则12–13:描述与分组
- max 255 characters
<description> - Grouping fields must NOT appear in — automatic deployment failure
<columns>
- 最多255个字符
<description> - 分组字段绝对不能出现在中 — 否则会导致部署失败
<columns>
Rule 14: Folder Metadata Requires <sharedTo>
<sharedTo>规则14:文件夹元数据需要<sharedTo>
<sharedTo>xml
<?xml version="1.0" encoding="UTF-8"?>
<ReportFolder xmlns="http://soap.sforce.com/2006/04/metadata">
<folderShares>
<accessLevel>Manage</accessLevel>
<sharedTo>AllInternalUsers</sharedTo>
<sharedToType>Group</sharedToType>
</folderShares>
<name>My Report Folder</name>
</ReportFolder>xml
<?xml version="1.0" encoding="UTF-8"?>
<ReportFolder xmlns="http://soap.sforce.com/2006/04/metadata">
<folderShares>
<accessLevel>Manage</accessLevel>
<sharedTo>AllInternalUsers</sharedTo>
<sharedToType>Group</sharedToType>
</folderShares>
<name>My Report Folder</name>
</ReportFolder>Rule 15: Valid Date Intervals Only
规则15:仅允许有效的日期间隔
Use for "this quarter", for "this year", for last 30 days. Do NOT use — it is not valid. See for the full list.
INTERVAL_CURRENTINTERVAL_CURYINTERVAL_LAST30INTERVAL_CURQreferences/date-intervals.md使用表示“本季度”,表示“本年”,表示“最近30天”。请勿使用 — 该值无效。完整列表详见。
INTERVAL_CURRENTINTERVAL_CURYINTERVAL_LAST30INTERVAL_CURQreferences/date-intervals.mdTop-Level Elements
顶层元素
| Element | Required | Notes |
|---|---|---|
| Yes | Report name (max 40 chars) |
| Yes | Report type API name |
| Yes | |
| Recommended | |
| Yes | Field columns — each has |
| No | Contains |
| Conditional | Row groupings: |
| Conditional | Column groupings (Matrix only) |
| Recommended | |
| No | See |
| No | Bucket field definitions |
| No | Cross-object filters ( |
| Recommended | |
| Recommended | |
| Recommended | |
| Recommended | Business purpose (max 255 chars) |
| Conditional | Joined format blocks |
| 元素 | 是否必填 | 说明 |
|---|---|---|
| 是 | 报表名称(最多40个字符) |
| 是 | 报表类型API名称 |
| 是 | |
| 推荐 | |
| 是 | 字段列 — 每个列包含 |
| 否 | 包含 |
| 条件必填 | 行分组: |
| 条件必填 | 列分组(仅矩阵报表支持) |
| 推荐 | |
| 否 | 详见 |
| 否 | 桶字段定义 |
| 否 | 跨对象筛选器( |
| 推荐 | |
| 推荐 | |
| 推荐 | |
| 推荐 | 业务用途(最多255个字符) |
| 条件必填 | 联合格式的块 |
Filter Syntax
筛选器语法
xml
<filter>
<criteriaItems>
<column>STAGE_NAME</column>
<operator>equals</operator>
<value>Closed Won</value>
</criteriaItems>
</filter>Multi-value picklist: Use ONE criteriaItem with comma-separated values:
xml
<criteriaItems>
<column>INDUSTRY</column>
<operator>equals</operator>
<value>Technology,Financial Services</value>
</criteriaItems>Common operators: , , , , , , , , , . Full list in .
equalsnotEquallessThangreaterThancontainsstartsWithincludesexcludesisBlanknotBlankreferences/filter-operations.mdxml
<filter>
<criteriaItems>
<column>STAGE_NAME</column>
<operator>equals</operator>
<value>Closed Won</value>
</criteriaItems>
</filter>多值选择列表: 使用一个criteriaItem,值用逗号分隔:
xml
<criteriaItems>
<column>INDUSTRY</column>
<operator>equals</operator>
<value>Technology,Financial Services</value>
</criteriaItems>常用运算符:、、、、、、、、、。完整列表详见。
equalsnotEquallessThangreaterThancontainsstartsWithincludesexcludesisBlanknotBlankreferences/filter-operations.mdGeneration Workflow
生成流程
- Gather Requirements — object, fields, groupings, filters, chart needs
- Determine Format — no groupings → Tabular; row groupings → Summary; row + column → Matrix; multiple objects → Joined
- Identify Column Names — call MCP tool to get valid platform column names for the report type
get_metadata_type_sections - Author Metadata — start from closest example in and adapt
examples/ - Create Folder — generate folder directory + with
<FolderName>-meta.xml<folderShares> - Validate — run through
references/verification-checklist.md
- 收集需求 — 对象、字段、分组、筛选器、图表需求
- 确定格式 — 无分组→表格报表;行分组→汇总报表;行+列分组→矩阵报表;多对象→联合报表
- 确认列名 — 调用MCP工具获取对应报表类型的有效平台列名
get_metadata_type_sections - 编写元数据 — 从中选择最接近的示例进行修改
examples/ - 创建文件夹 — 生成文件夹目录 + 包含的
<folderShares>文件<FolderName>-meta.xml - 验证 — 按照进行检查
references/verification-checklist.md
Reference File Index
参考文件索引
| File | When to read |
|---|---|
| Step 3 — column name mappings per report type |
| When setting timeFrameFilter intervals |
| When adding a chart — all 17 types + legendPosition rules |
| When building filters — complete operator reference |
| Step 6 — pre-deploy validation |
| When fields are missing or deployment fails |
| Tabular report template |
| Summary report with chart |
| Matrix report template |
| Filtered report with time frame |
| 文件 | 阅读时机 |
|---|---|
| 步骤3 — 各报表类型的列名映射 |
| 设置timeFrameFilter间隔时 |
| 添加图表时 — 全部17种类型 + 图例位置规则 |
| 构建筛选器时 — 完整运算符参考 |
| 步骤6 — 部署前验证 |
| 字段缺失或部署失败时 |
| 表格报表模板 |
| 带图表的汇总报表 |
| 矩阵报表模板 |
| 带时间范围的筛选报表 |