mcpField
G
generating-custom-tab

generating-custom-tab

github.com/forcedotcom开发1.1k3.9k 次安装1 天前更新
代码仓库

关于 generating-custom-tab

用于创建 Salesforce 选项卡元数据的技能,选项卡可导航至对象、外部网页或 Visualforce 页面。重点说明有效的 XML 元素、文件命名及部署要求。

主要功能

  1. 01创建对象、网页和 Visualforce 选项卡
  2. 02设置选项卡标签、URL 和页面名称
  3. 03遵循 XML 元素白名单
  4. 04应用选项卡文件命名规则
  5. 05配置可见性与图标样式

适用场景

  1. 01添加自定义对象选项卡
  2. 02将应用选项卡链接到网站
  3. 03通过选项卡提供 Visualforce 页面入口

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/forcedotcom/sf-skills --skill generating-custom-tab

安装后在 Claude Code 中输入/generating-custom-tab确认已加载。

详细介绍

何时使用此技能

在以下情况下使用此技能:

  • 为对象、网页或 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 应用程序
  • 自定义应用程序:可包含在自定义应用程序中
  • 社区应用程序:可用于社区应用程序

🔗 集成点

  • 对象关系:链接到相关对象记录
  • Web 内容:外部网站集成
  • Visualforce 页面:自定义页面功能
  • Lightning 组件:现代组件集成

✅ 最佳实践

  • 使用清晰、描述性强的选项卡标签
  • 根据功能选择合适的选项卡类型
  • 为每个选项卡选择独特且符合上下文的图案 — 不要默认让所有选项卡使用相同图标
  • 考虑用户体验和导航流程
  • 在不同应用程序中测试选项卡功能
  • 确保权限和可见性设置正确
  • 遵循一致的命名规范
  • 对象选项卡文件必须只包含 <customObject>true</customObject> 和 <motif> — 不得包含其他内容
  • Web 选项卡文件必须只包含:<customObject>false</customObject>、<label>、<motif>、<url>、<urlEncodingKey>,以及可选的 <description>、<frameHeight> — 不得包含其他内容
  • 切勿包含 <isHidden>、<tabVisibility>、<type>、<mobileReady> 或空元素

评论

支持 Markdown