关于 platform-custom-tab-generate
为 Salesforce 元数据生成提供 CustomTab 规范的技能,面向创建或排查对象、网页和 Visualforce 标签页的开发者。重点说明各标签类型的必需元素及严格 XML 白名单。
主要功能
- 01定义对象、网页和 Visualforce 标签页
- 02列出各类型允许的 XML 元素
- 03说明标签图标与可见性设置
- 04提供部署排错和配置建议
适用场景
- 01创建对象导航标签页
- 02将外部网页加入应用导航
- 03配置 Visualforce 页面标签
- 04排查自定义标签页部署错误
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ forcedotcom/ sf-skills --skill platform-custom-tab-generate安装后在 Claude Code 中输入/platform-custom-tab-generate确认已加载。
详细介绍
何时使用此技能
在需要以下操作时使用此技能:
- 为对象、网页或 Visualforce 页面创建选项卡
- 向应用程序添加导航选项卡
- 配置选项卡的可见性和访问权限
- 排查与自定义选项卡相关的部署错误
规范
CustomTab 元数据规范
概述
用于在 Salesforce 应用程序中导航至对象、网页内容或 Visualforce 页面的自定义选项卡。
用途
- 提供自定义对象的导航入口
- 链接到外部网页内容
- 访问 Visualforce 页面
- 组织应用程序导航
必需属性
核心选项卡属性
- customObject:自定义对象选项卡设为
true,其他选项卡均设为false。 - motif:选项卡图标样式——选择与对象用途在语义上匹配的 motif。请勿为每个选项卡重复使用同一个 motif。
- label:显示名称(仅非对象选项卡需要;对象选项卡会继承对象的标签)
- url:网页 URL(用于网页选项卡)
- page:Visualforce 页面名称(用于 Visualforce 选项卡)
严格的元素允许列表——请先阅读
根元素必须始终为 <CustomTab>(不能是 <Tab>)。 XML 命名空间必须为 xmlns="http://soap.sforce.com/2006/04/metadata"。
只有以下列出的元素有效。任何未列出的元素都会导致部署错误。
| 选项卡类型 | 仅允许使用以下元素(不得使用其他元素) |
|---|---|
| 对象选项卡 | <customObject>(必需,设为 true)、<motif>(必需)、<description>(可选) |
| 网页选项卡 | <customObject>(必需,设为 false)、<label>(必需)、<motif>(必需)、<url>(必需)、<urlEncodingKey>(必需,设为 UTF-8)、<description>(可选)、<frameHeight>(可选) |
| Visualforce 选项卡 | <customObject>(必需,设为 false)、<label>(必需)、<motif>(必需)、<page>(必需)、<description>(可选) |
禁止使用的元素(其中任一元素都会导致部署错误)
<sobjectName>、<name>、<fullName>、<apiVersion>、<isHidden>、<tabVisibility>、<type>、<mobileReady>、<urlFrameHeight>、<urlType>、<urlRedirect>、<encodingKey>、<height>、<auraComponent>
还禁止:
- 在对象选项卡中使用
<label>(对象选项卡会继承自定义对象的标签) - 在网页选项卡中使用
<page>(仅用于 Visualforce 选项卡) - 使用空元素,例如
<page></page>或<description></description> - 使用上方允许列表中的表格未列出的任何元素
选项卡类型
对象选项卡
- 用途:导航至自定义对象或标准对象
- 文件名决定对象:
{ObjectApiName}.tab-meta.xml(例如,Space_Station__c.tab-meta.xml) - 必需元素:
<customObject>true</customObject>和<motif> - 正确示例(适用于
Space_Station__c.tab-meta.xml):
<?xml version="1.0" encoding="UTF-8"?>
<CustomTab xmlns="http://soap.sforce.com/2006/04/metadata">
<customObject>true</customObject>
<motif>Custom39: Telescope</motif>
</CustomTab>
- 正确示例(适用于
Supply__c.tab-meta.xml——注意 motif 不同):
<?xml version="1.0" encoding="UTF-8"?>
<CustomTab xmlns="http://soap.sforce.com/2006/04/metadata">
<customObject>true</customObject>
<motif>Custom98: Truck</motif>
</CustomTab>
- 错误示例——请勿添加
<sobjectName>、<name>、<fullName>或<label>:
<CustomTab xmlns="http://soap.sforce.com/2006/04/metadata">
<sobjectName>Space_Station__c</sobjectName>
<label>Space Station</label>
<customObject>true</customObject>
<motif>Custom57: Desert</motif>
</CustomTab>
网页选项卡
- 用途:链接到外部网站或 Web 应用程序
- 文件名:使用描述性名称:
{TabName}.tab-meta.xml(例如,Knowledge_Base.tab-meta.xml) - 请原样复制此模板——仅替换占位值。请勿添加、删除或重命名任何 XML 元素:
<?xml version="1.0" encoding="UTF-8"?>
<CustomTab xmlns="http://soap.sforce.com/2006/04/metadata">
<customObject>false</customObject>
<description>REPLACE_WITH_DESCRIPTION</description>
<frameHeight>600</frameHeight>
<label>REPLACE_WITH_LABEL</label>
<motif>REPLACE_WITH_MOTIF</motif>
<url>REPLACE_WITH_URL</url>
<urlEncodingKey>UTF-8</urlEncodingKey>
</CustomTab>
- **上述 7 个元素是网页选项卡文件中唯一允许使用的元素。**请勿添加任何其他元素。
<description>元素为可选项——如不需要,可以移除,但不要添加其他内容。
Visualforce 选项卡
- 用途:访问自定义 Visualforce 页面
- 文件名:
{TabName}.tab-meta.xml(例如,Custom_Page_Tab.tab-meta.xml) - 必需元素:
<customObject>false</customObject>、<label>、<motif>、<page> - 正确示例:
<?xml version="1.0" encoding="UTF-8"?>
<CustomTab xmlns="http://soap.sforce.com/2006/04/metadata">
<customObject>false</customObject>
<label>Custom Page</label>
<motif>Custom46: Computer</motif>
<page>CustomPage</page>
</CustomTab>
选项卡配置
选项卡样式
- 默认:使用标准选项卡样式
- 自定义:如有需要,可以指定自定义选项卡样式
选项卡可见性
- 默认:对所有有权限的用户可见
- 自定义:可针对特定用户配置文件进行配置
支持的应用
- 标准应用:可用于标准 Salesforce 应用
- 自定义应用:可包含在自定义应用中
- 社区应用:可用于社区应用
集成点
- 对象关系:链接到相关对象记录
- 网页内容:外部网站集成
- Visualforce 页面:自定义页面功能
- Lightning 组件:现代组件集成
最佳实践
- 使用清晰且有描述性的选项卡标签
- 根据功能选择合适的选项卡类型
- 为每个选项卡选择独特且符合上下文的图案 — 不要默认让所有选项卡使用相同图标
- 考虑用户体验和导航流程
- 在不同应用中测试选项卡功能
- 确保权限和可见性设置正确
- 遵循一致的命名约定
- 对象选项卡文件只能包含
<customObject>true</customObject>和<motif>— 不得包含其他内容 - Web 选项卡文件只能包含:
<customObject>false</customObject>、<label>、<motif>、<url>、<urlEncodingKey>,以及可选的<description>、<frameHeight>— 不得包含其他内容 - 切勿包含
<isHidden>、<tabVisibility>、<type>、<mobileReady>或空元素
评论
支持 Markdown