<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Jair Talks Salesforce</title>
    <description>Notes on Salesforce, AI and architecture.</description>
    <language>zh-CN</language>
    <link>https://jairzh.com/</link>
    <atom:link href="https://jairzh.com/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Sat, 03 Oct 2026 21:55:49 +0800</pubDate>
    <lastBuildDate>Sat, 03 Oct 2026 21:55:49 +0800</lastBuildDate>
    <generator>Jekyll v3.10.0</generator>
    
      <item>
        <title>Dreamforce 2026：Salesforce MCP 篇</title>
        <description>&lt;p&gt;今年去了 Dreamforce 2026 现场。每年 Dreamforce 都有一些动手的小实验，叫 &lt;strong&gt;Mini Hacks&lt;/strong&gt;，用来让大家体验当年主推的技术。今年一共五个题目，&lt;strong&gt;三个都和 MCP 有关&lt;/strong&gt;，剩下两个一个讲模型选择，一个讲 React。&lt;/p&gt;

&lt;p&gt;题目的分布本身就说明了方向：&lt;strong&gt;Salesforce 不再只在自己的界面里做 AI，而是要把 CRM 的能力送到用户正在用的 AI 工具里。&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;这篇不复述操作步骤（文末有官方 Workshop 和 Trailhead 链接），只讲作为一线开发者，我觉得最值得关注的五件事。&lt;/p&gt;

&lt;h3 id=&quot;1-多了一层界面层aiforce&quot;&gt;1. 多了一层「界面层」：AIforce&lt;/h3&gt;

&lt;p&gt;按今年 Keynote 的说法，Salesforce 现在分成四层：
&lt;img src=&quot;https://article.asset.jairzh.com/img/2026/10/scr-20261003-jvml-d83cf5.jpeg&quot; alt=&quot;scr-20261003-jvml-d83cf5&quot; /&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;界面层&lt;/strong&gt;：AIforce。首批入口有 Claude 里的 Claudeforce、Slack 里的 Slackforce，以及 Lightning 里的 Agentforce Coworker&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Agent 层&lt;/strong&gt;：Agentforce&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;应用与语义层&lt;/strong&gt;：Sales Cloud、Service Cloud 等&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;数据层&lt;/strong&gt;：Data 360&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;为什么要加一层界面层？员工一天的工作不只在 CRM 里，还有邮件、文档、PPT 和各种沟通工具。越来越多的人直接在 AI 工具里干活，CRM 如果不进入这个生态，就会被孤立；让用户专门回到 Salesforce 里去用 Agent，体验并不好。&lt;/p&gt;

&lt;p&gt;把能力送出去的方式就是 &lt;strong&gt;MCP（Model Context Protocol）&lt;/strong&gt;：AI 客户端和外部服务之间的标准协议。服务把能力暴露成 Tools，每个 Tool 带一段自然语言描述，AI 根据描述决定调用哪个。&lt;/p&gt;

&lt;p&gt;在 Salesforce 里，Setup 里有 MCP 设置，标准 Server 自带 CRUD 和搜索；自定义 Server 可以把 Flow、Apex、Agent、Prompt Template 加成 Tools。配好之后得到一个 URL，填进任何支持 MCP 的客户端就能用。Tableau Next 和 Slack 两个 Mini Hacks 也是同一个套路，只是能力的来源和入口不同。&lt;/p&gt;

&lt;h3 id=&quot;2-开发的重心从做页面到做-tools&quot;&gt;2. 开发的重心：从做页面，到做 Tools&lt;/h3&gt;

&lt;p&gt;Mini Hack 里我先试了只用标准 Server：AI 确实能靠 CRUD 完成一个多步骤的预约流程，但要逐个对象查询、逐个创建，&lt;strong&gt;很慢，而且每次都要重新理解对象之间的关系&lt;/strong&gt;，结果也不稳定。&lt;/p&gt;

&lt;p&gt;换成把整个流程封装成一个 Flow、再作为一个 Tool 暴露出去，一次调用就完成了。&lt;/p&gt;

&lt;p&gt;我的体会是：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;高频的核心流程，要封装成一个粒度合适的 Tool&lt;/strong&gt;，不要指望 AI 用 CRUD 自己拼。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Tool 的描述就是新的 UI&lt;/strong&gt;。以前用户看的是按钮和表单，现在「看」的是模型，名字、描述、参数说明写得清不清楚，直接决定 AI 会不会选对、传对。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;标准 Server 不能改，但可以组合&lt;/strong&gt;。新建自定义 Server，用 Add from Server 把需要的标准 Tools 加进来，再加上自己写的 Apex Action，按角色组合成不同的 Server。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Agent 有大脑，没有手脚，能做什么取决于我们给它的 Tools。&lt;/strong&gt;&lt;/p&gt;

&lt;h3 id=&quot;3-认证和安全要提前想清楚&quot;&gt;3. 认证和安全要提前想清楚&lt;/h3&gt;

&lt;p&gt;连接走的是 &lt;strong&gt;External Client App（ECA）&lt;/strong&gt;，几个关键配置容易踩坑：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;OAuth Scope 要选 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mcp_api&lt;/code&gt;，普通的 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;api&lt;/code&gt; 不行，另外加上 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;refresh_token&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;勾选 Require PKCE，以及 Issue JWT-based access tokens for named users&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;比配置更重要的是&lt;strong&gt;以谁的身份运行&lt;/strong&gt;。外部 AI 调用你暴露的 Apex 时，是以授权用户的身份来的，所以自己写的 Apex Action 要老老实实遵守共享规则和字段权限（&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;with sharing&lt;/code&gt;、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;WITH USER_MODE&lt;/code&gt;），模型传进来的参数也要当成用户输入来对待，不能直接拼进动态 SOQL。以前「只有内部页面会调用」的假设，在 MCP 时代不成立了。&lt;/p&gt;

&lt;p&gt;另外 Salesforce 在推出了新的权限配置，叫 &lt;strong&gt;Scoped Access&lt;/strong&gt;，这个可以解决在 AI 客户端使用 user 什么去运用，但 user 什么权限又太大的问题。&lt;strong&gt;Scoped Access&lt;/strong&gt; 可以单独在 User 的基础上去掉/增加相关的权限，保证在 AI 环境下的安全性。&lt;/p&gt;

&lt;h3 id=&quot;4-成本mcp-调用将按-flex-credits-计费&quot;&gt;4. 成本：MCP 调用将按 Flex Credits 计费&lt;/h3&gt;

&lt;p&gt;这一点做方案时很容易忽略。现场分会场提到，&lt;strong&gt;生产环境里成功的 MCP 调用会消耗 Flex Credits&lt;/strong&gt;。按公开报道，每次成功调用会计为一次「Headless Platform Interaction」，在 Digital Wallet 里统计；具体倍率官方还没公布，计划 11 月前后随 Agent 注册和安全管控一起推出，开始计费前会提前 30 天通知。&lt;/p&gt;

&lt;p&gt;这反过来又印证了第 2 点：&lt;strong&gt;Tool 粒度越合适，调用次数越少，成本越低。&lt;/strong&gt; 让 AI 用 CRUD 一步步拼，不只是慢，还贵。&lt;/p&gt;

&lt;h3 id=&quot;5-模型和前端也在同步开放&quot;&gt;5. 模型和前端也在同步开放&lt;/h3&gt;

&lt;p&gt;另外两个 Mini Hacks 看起来和 MCP 无关，其实是同一个思路：&lt;strong&gt;更开放&lt;/strong&gt;。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;模型可以换&lt;/strong&gt;：Prompt Template、Agent 可以用不同的模型，新版 Builder（Agent Script）里每个 Subagent 还能用 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;model_config&lt;/code&gt; 单独指定。经验是：Prompt 优化到头了效果还不稳，就换个模型测；先用低档模型打底，只给复杂的 Subagent 配强模型；换完模型一定要把测试用例重跑一遍，不同模型调 Tools 的习惯不一样。老版 Builder 的 Agent 可以用官方 Upgrade 功能转成新版。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;前端可以用 React&lt;/strong&gt;：Multi-Framework 已经 GA，React 应用以 UI Bundle 的形式部署在 Salesforce 上。现场我问了「React 还是 LWC」，官方的回答很直接：团队擅长 React 就用 React。我的判断是，对外、复杂的单页应用适合 React；需要 Lightning 标准组件的内部应用，LWC 依然是主力。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;动手实践&quot;&gt;动手实践&lt;/h3&gt;

&lt;p&gt;目前 Trailhead 已经同步推出 AIforce 相关的模块，有兴趣可以去 Trailhead 搜索，动手实践体验下。&lt;/p&gt;

&lt;h3 id=&quot;总结&quot;&gt;总结&lt;/h3&gt;

&lt;p&gt;Dreamforce 2026 给我最大的感受是：&lt;strong&gt;Salesforce 开发者的工作对象正在改变。&lt;/strong&gt; 过去我们给人做页面，现在还要给 AI 做 Tools：粒度要合适，描述要写清楚，权限要守住，另外还有相关的 AI 成本问题。。&lt;/p&gt;

&lt;hr /&gt;

&lt;blockquote&gt;
  &lt;p&gt;本文首发于微信公众号「SalesforceTalk」，&lt;a href=&quot;https://mp.weixin.qq.com/s/fECELCxZHQV_L_18pKWbCg&quot;&gt;阅读原文&lt;/a&gt;。&lt;/p&gt;
&lt;/blockquote&gt;
</description>
        <pubDate>Sat, 03 Oct 2026 00:00:00 +0800</pubDate>
        <link>https://jairzh.com/blog/2026/10/03/dreamforce-2026-salesforce-mcp</link>
        <guid isPermaLink="true">https://jairzh.com/blog/2026/10/03/dreamforce-2026-salesforce-mcp</guid>
        
        <category>dreamforce</category>
        
        <category>mcp</category>
        
        <category>agentforce</category>
        
        <category>aiforce</category>
        
        
        <category>ai</category>
        
      </item>
    
      <item>
        <title>Agentic 时代 Salesforce 开发和定制的转化</title>
        <description>&lt;p&gt;一张图看懂 Agentic AI 如何重塑 Salesforce Admin 与 Developer 的工作方式。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/wechat/agentic-era-salesforce-development/01.png&quot; alt=&quot;Agentic 时代 Salesforce 开发和定制的转化&quot; /&gt;&lt;/p&gt;

&lt;p&gt;信息来源：&lt;a href=&quot;https://www.salesforce.com/plus/experience/tdx_2026/series/tdx_2026_highlights/episode/episode-s1e33&quot;&gt;TDX 2026 Highlights · S1E33&lt;/a&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;blockquote&gt;
  &lt;p&gt;本文首发于微信公众号「SalesforceTalk」，&lt;a href=&quot;https://mp.weixin.qq.com/s/iSv1wyZ011puzgOYRpLRtQ&quot;&gt;阅读原文&lt;/a&gt;。&lt;/p&gt;
&lt;/blockquote&gt;
</description>
        <pubDate>Mon, 25 May 2026 20:00:00 +0800</pubDate>
        <link>https://jairzh.com/blog/2026/05/25/agentic-era-salesforce-development</link>
        <guid isPermaLink="true">https://jairzh.com/blog/2026/05/25/agentic-era-salesforce-development</guid>
        
        <category>agentic-ai</category>
        
        <category>tdx</category>
        
        
        <category>ai</category>
        
      </item>
    
      <item>
        <title>Salesforce Reactive Screen Flow</title>
        <description>&lt;p&gt;Salesforce Screen Flow 通过 Reactivity 支持实时 UI 的渲染，可以通过组件之间相互传值，利用 Formula 作为中转实现复杂的计算，实现相互的控制，比如禁用组件，动态改变组件的值等。&lt;/p&gt;

&lt;p&gt;比如：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;组件控制组件（直接联动）&lt;/strong&gt;：将复选框组件（Confirmation）的布尔输出直接绑定到文本组件（Subject）的 Disabled（禁用）属性。当用户勾选确认时，文本框瞬间置灰，防止二次修改。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;公式中转控制（逻辑路由）&lt;/strong&gt;：利用文本组件输入的值作为公式（Formula）的入参，通过公式进行文本模糊匹配（如判断是否包含 “urgent” ）。公式计算出的结果（如返回 “High”）再实时塞给单选按钮（Priority）作为默认值，实现智能引导。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;多源输入计算（复杂数学/日期运算）&lt;/strong&gt;：将单选按钮选择的“优先级天数”与滑块组件（Slider）拖动的“微调天数”共同作为输入源，交由日期公式进行实时加减，直接驱动最终日期组件（Due Date）的实时渲染。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;条件显示控制（UI 显隐分流）&lt;/strong&gt;：将滑块组件的数值输出作为下游 Display Text 组件的“条件可见性（Conditional Visibility）”判定条件。当拖动滑块 &amp;gt; 3 天时瞬间弹出审批警告，&amp;lt;3 天时则自动切换为绿色通行提示，实现单页内的动态交互引导。&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;blockquote&gt;
  &lt;p&gt;本文首发于微信公众号「SalesforceTalk」，&lt;a href=&quot;https://mp.weixin.qq.com/s/3TXnZwBdlrJxRXBdXvyDWQ&quot;&gt;阅读原文&lt;/a&gt;。&lt;/p&gt;
&lt;/blockquote&gt;
</description>
        <pubDate>Sun, 24 May 2026 11:33:23 +0800</pubDate>
        <link>https://jairzh.com/blog/2026/05/24/salesforce-reactive-screen-flow</link>
        <guid isPermaLink="true">https://jairzh.com/blog/2026/05/24/salesforce-reactive-screen-flow</guid>
        
        <category>screen-flow</category>
        
        
        <category>flow</category>
        
      </item>
    
      <item>
        <title>Salesforce Archive 解决 Org 数据膨胀与存储成本的归档方案</title>
        <description>&lt;p&gt;随着 Org 使用时间的增长，面临的一个挑战就是：&lt;strong&gt;数据爆炸&lt;/strong&gt;。&lt;/p&gt;

&lt;p&gt;当 Standard Objects（如 Case, Task, Event）或 Custom Objects 的记录数突破千万级，不仅会频繁触发 Storage Limit 警告，还会直接拖慢 Report 运行速度和 Global Search 的响应时间。&lt;/p&gt;

&lt;p&gt;面对这种情况，单纯的 “Delete” 往往不可行（由于审计和合规要求），而购买额外的 Data Storage 费用又相当昂贵。今天在 Trailhead 上看到 &lt;strong&gt;Salesforce Archive&lt;/strong&gt; 这个产品，详细了解下，这是一个专门解决“过期数据去留”问题的归档方案，简单介绍下。&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Note: &lt;strong&gt;Salesforce Archive&lt;/strong&gt; 需要单独购买，目前官方没有给出明确的价格。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;什么是-salesforce-archive&quot;&gt;什么是 Salesforce Archive？&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/wechat/salesforce-archive/01.png&quot; alt=&quot;Salesforce Archive 界面截图&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Salesforce Archive&lt;/strong&gt; 是 Salesforce 提供的一种解决方案，旨在将 Org 中“低频访问”或“过期”的数据，迁移到低成本的外部存储中。&lt;/p&gt;

&lt;p&gt;它的核心价值在于&lt;strong&gt;分离冷热数据&lt;/strong&gt;：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;热数据 (Hot Data)&lt;/strong&gt;：保留在 Salesforce 主存储中，用于日常高频业务操作。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;冷数据 (Cold Data)&lt;/strong&gt;：迁移至外部存储（如 AWS, Azure），但在 Salesforce Org 内部依然保持可见和可搜索。&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;核心特性-key-features&quot;&gt;核心特性 (Key Features)&lt;/h2&gt;

&lt;p&gt;根据官方文档和网上的实践总结，Archive 方案主要包含以下能力：&lt;/p&gt;

&lt;h3 id=&quot;1-自动化归档策略-automated-policies&quot;&gt;1. 自动化归档策略 (Automated Policies)&lt;/h3&gt;

&lt;p&gt;你不需要手动去写 Batch Apex 来迁移数据。系统支持配置基于规则的策略（例如：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CreatedDate &amp;gt; 3 years&lt;/code&gt; 且 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Status = &apos;Closed&apos;&lt;/code&gt;），自动识别并移动符合条件的数据。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/wechat/salesforce-archive/02.png&quot; alt=&quot;配置归档策略&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;2-无缝的可视化访问-visual-access&quot;&gt;2. 无缝的可视化访问 (Visual Access)&lt;/h3&gt;

&lt;p&gt;这是 Archive 区别于传统 “Data Export” 备份最大的不同。&lt;/p&gt;

&lt;p&gt;数据虽然物理上移出了 Salesforce 的核心 Storage，但在 UI 层面上，用户依然可以通过相关的 Component 或列表查看到这些归档数据。对于 End User 来说，体验是无缝的，不需要切换系统去查找历史记录。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/wechat/salesforce-archive/03.png&quot; alt=&quot;在 Salesforce 中查看已归档的数据&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;3-外部低成本存储&quot;&gt;3. 外部低成本存储&lt;/h3&gt;

&lt;p&gt;底层存储通常对接 AWS S3、Azure 等云存储服务。相比于 Salesforce 原生的 Data Storage 价格，这些外部存储的成本可以更低。&lt;/p&gt;

&lt;h3 id=&quot;4-合规与审计-compliance&quot;&gt;4. 合规与审计 (Compliance)&lt;/h3&gt;

&lt;p&gt;针对医疗、金融等强监管行业，数据往往需要保留 7-10 年。Archive 方案能够满足这种长期保留（Retention）的需求，同时不占用昂贵的生产环境资源。&lt;/p&gt;

&lt;h2 id=&quot;典型使用场景&quot;&gt;典型使用场景&lt;/h2&gt;

&lt;p&gt;如果你的 Org 遇到以下瓶颈，可以考虑引入 Archive 策略：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;存储告警&lt;/strong&gt;：Data Storage 使用率长期处于 90%+，且主要被数年前的历史数据（History, Logs, Closed Cases）占用。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;性能下降&lt;/strong&gt;：由于单表数据量过大（Data Skew），导致 Report 超时、List View 加载缓慢或 SOQL 查询效率低下。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;审计需求&lt;/strong&gt;：业务部门要求必须保留所有历史记录以备审计，但 IT 预算无法支撑无限制购买 Salesforce Storage。&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;定价模型-pricing&quot;&gt;定价模型 (Pricing)&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;注：Salesforce 的具体 SKU 定价通常不公开透明，且取决于合同（Contract）、地区和企业规模，以下信息主要整理自社区讨论，仅供参考。&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Salesforce Archive 并不像 License 那样有固定的 List Price，它通常采用 &lt;strong&gt;定制报价&lt;/strong&gt; 的模式。&lt;/p&gt;

&lt;p&gt;根据社区（Community）反馈的信息：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;参考单价&lt;/strong&gt;：约为 $10/GB/年。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;起售门槛&lt;/strong&gt;：部分案例提到有最低存储量要求（如 50GB 起），这意味着每年的起步预算可能在 $6,000 左右。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;相比于 Salesforce 原生 Data Storage 的扩容价格，Archive 的单位成本显然更具优势，特别是对于 TB 级别的数据量。&lt;/p&gt;

&lt;h2 id=&quot;总结与建议&quot;&gt;总结与建议&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Salesforce Archive&lt;/strong&gt; 本质上是用“架构复杂度”换取“成本与性能”的平衡。&lt;/p&gt;

&lt;p&gt;对于数据量尚未达到千万级的 Org，配置合理的 &lt;strong&gt;Retention Policy&lt;/strong&gt; 并定期通过 ETL 工具导出备份后物理删除，可能是一个更轻量级的选择。但对于企业级 Org，引入自动化的 Archive 机制是必然趋势。&lt;/p&gt;

&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.salesforce.com/platform/data-archiving-solutions/&quot;&gt;Salesforce Archive 官方介绍&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;blockquote&gt;
  &lt;p&gt;本文首发于微信公众号「SalesforceTalk」，&lt;a href=&quot;https://mp.weixin.qq.com/s/VpsO5Xo0e_TmpsRp1s8LZQ&quot;&gt;阅读原文&lt;/a&gt;。&lt;/p&gt;
&lt;/blockquote&gt;
</description>
        <pubDate>Sat, 31 Jan 2026 18:12:53 +0800</pubDate>
        <link>https://jairzh.com/blog/2026/01/31/salesforce-archive</link>
        <guid isPermaLink="true">https://jairzh.com/blog/2026/01/31/salesforce-archive</guid>
        
        <category>archive</category>
        
        <category>storage</category>
        
        
        <category>data</category>
        
      </item>
    
      <item>
        <title>用 AI 辅助制定 2026 Salesforce 学习计划</title>
        <description>&lt;p&gt;每年年初制定学习计划是惯例。作为 Salesforce 从业者，通常我会根据 Trailhead 官网路径结合经验人工筛选证书目标。今年我决定换个思路：引入 AI（ChatGPT 和 Gemini）作为“咨询顾问”，对我的计划进行交叉验证。&lt;/p&gt;

&lt;h2 id=&quot;1-数据准备-chatgpt&quot;&gt;1. 数据准备 (ChatGPT)&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;遇到的坑&lt;/strong&gt;：起初直接让 Gemini 给推荐，结果给出来的结果都是我已经考过的证书。还是缺少相关的数据，正好 Trailhead Profile 上数据都有。尝试直接把 Trailhead Profile 的 URL 投喂给 Gemini，但受限于页面反爬策略，无法读取有效内容。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;解决方案&lt;/strong&gt;：使用 ChatGPT (配合 Atlas 浏览器) 访问 Trailhead 主页，利用其强大的文本提取能力进行“人肉”抓取。&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Prompt:&lt;/strong&gt;&lt;br /&gt;
把这个页面的信息，详细输出成 markdown 格式，保留所有详细的信息，不要总结。英文输出就可以。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;注：Trailhead 主页内容不多，直接手动 Copy 页面文字也可以&lt;/em&gt;&lt;/p&gt;

&lt;h2 id=&quot;2-分析与推荐-gemini&quot;&gt;2. 分析与推荐 (Gemini)&lt;/h2&gt;

&lt;p&gt;将 ChatGPT 输出的 Markdown 内容（包含 Badge、Superbadge、Skill points 分布等）完整复制，保存为一个 &lt;strong&gt;Google Docs&lt;/strong&gt; 文档。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Why Google Docs?&lt;/strong&gt;&lt;br /&gt;
Gemini 可以直接读取 Workspace 文档内容，不仅规避了对话框字数限制，该文档还可以作为后续复盘的基准数据。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;在 Gemini 中直接挂载该文档，输入分析指令：&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Analysis Prompt:&lt;/strong&gt;&lt;br /&gt;
基于这份 Trailhead Profile 的学习历史和技能分布，结合当前的 Salesforce 生态趋势，为我推荐 2026 年最值得考取的两个证书，并给出理由。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;分析结果&quot;&gt;分析结果&lt;/h2&gt;

&lt;p&gt;Gemini 在读取文档后，输出的分析报告带来了一次小小的“震撼”：&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;结果一致性&lt;/strong&gt;：Gemini 推荐的两个证书，与我人工选定的目标&lt;strong&gt;完全一致&lt;/strong&gt;。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;逻辑推导&lt;/strong&gt;：
    &lt;ul&gt;
      &lt;li&gt;它准确识别了我现有技能树中的“进阶缺口”。&lt;/li&gt;
      &lt;li&gt;推荐理由（Why）与我制定计划时的初衷高度重合。&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;总结&quot;&gt;总结&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;给的数据越准确，AI 潜力越大。&lt;/strong&gt;如果效果不理想，可以尝试把你的职业信息补充一下，包括工作时间，工作职责等。&lt;/p&gt;

&lt;p&gt;最后分享一个通用的年度计划 Prompt，可以让 AI 充当教练角色：&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;write my 2026 goals for me. 
Ask me the most important questions 
to craft the best possible 
set of goals for me
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;blockquote&gt;
  &lt;p&gt;本文首发于微信公众号「SalesforceTalk」，&lt;a href=&quot;https://mp.weixin.qq.com/s/muw35nl6bii01wvetOuD2g&quot;&gt;阅读原文&lt;/a&gt;。&lt;/p&gt;
&lt;/blockquote&gt;
</description>
        <pubDate>Sun, 18 Jan 2026 12:56:57 +0800</pubDate>
        <link>https://jairzh.com/blog/2026/01/18/ai-assisted-salesforce-learning-plan-2026</link>
        <guid isPermaLink="true">https://jairzh.com/blog/2026/01/18/ai-assisted-salesforce-learning-plan-2026</guid>
        
        <category>certification</category>
        
        <category>learning-plan</category>
        
        
        <category>ai</category>
        
      </item>
    
      <item>
        <title>Agentforce Specialist 考点解析：音频系列合集</title>
        <description>&lt;p&gt;2025 年 12 月，我按照 Agentforce Specialist 的考试大纲（Exam Guide），用 NotebookLM 基于 Trailhead 资料生成了 4 期考点解析音频，发在公众号「SalesforceTalk」上，每期 17 到 18 分钟。这里把每期对应的考点和权重整理到一起，音频点链接到公众号收听。&lt;/p&gt;

&lt;h2 id=&quot;1-ai-agents35&quot;&gt;1. AI Agents（35%）&lt;/h2&gt;

&lt;p&gt;收听：&lt;a href=&quot;https://mp.weixin.qq.com/s/VzEtLYsFnBYdFIEG_39RMw&quot;&gt;Agentforce Specialist - AI Agents 考点解析&lt;/a&gt;（17:25）&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Given a use case, manage deterministic behavior for the agent using filters and variables.&lt;/li&gt;
  &lt;li&gt;Explain how an agent works and how the reasoning engine powers Agentforce.&lt;/li&gt;
  &lt;li&gt;Given a scenario, select and configure standard topics, custom topics, standard agent actions, and custom agent actions based on agent types.&lt;/li&gt;
  &lt;li&gt;Explain how to manage Agentforce security, including the concept of the Agent User and how it applies to an Employee Agent, Service Agent, or Sales Agent.&lt;/li&gt;
  &lt;li&gt;Given a scenario, identify when to use an Employee agent, Service agent, or Sales agent.&lt;/li&gt;
  &lt;li&gt;Explain the process for connecting agents to various channels such as digital experience, email, and Slack.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;2-prompt-engineering20&quot;&gt;2. Prompt Engineering（20%）&lt;/h2&gt;

&lt;p&gt;收听：&lt;a href=&quot;https://mp.weixin.qq.com/s/TGQLeZ2bd7-uL5i0eaeZSQ&quot;&gt;Agentforce Specialist - Prompt Engineering 考点解析&lt;/a&gt;（18:09）&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Given business requirements, identify when it’s appropriate to use Prompt Builder.&lt;/li&gt;
  &lt;li&gt;Identify the right user roles to manage and execute prompt templates.&lt;/li&gt;
  &lt;li&gt;Identify the considerations for creating a prompt template using field generation and flex types.&lt;/li&gt;
  &lt;li&gt;Given a scenario, identify the appropriate grounding technique.&lt;/li&gt;
  &lt;li&gt;Explain the process for creating, activating, and executing prompt templates.&lt;/li&gt;
  &lt;li&gt;Explain how to use best practices for writing effective prompts.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;3-data-cloud-for-agentforce20&quot;&gt;3. Data Cloud for Agentforce（20%）&lt;/h2&gt;

&lt;p&gt;收听：&lt;a href=&quot;https://mp.weixin.qq.com/s/zNleCZ80BS6Z4sWpZ_PL5A&quot;&gt;Agentforce Specialist - Data Cloud for Agentforce 考点解析&lt;/a&gt;（17:24）&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Explain the considerations of Agentforce Data Library and its types.&lt;/li&gt;
  &lt;li&gt;Given a scenario, improve an agent’s response with unstructured data using chunking and indexing.&lt;/li&gt;
  &lt;li&gt;Identify the considerations for retrievers in Data Cloud such as individual and ensemble.&lt;/li&gt;
  &lt;li&gt;Given a scenario, identify the considerations for search type such as keyword, vector, and hybrid.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;4-development-lifecycle20和-multi-agent-interoperability5&quot;&gt;4. Development Lifecycle（20%）和 Multi-Agent Interoperability（5%）&lt;/h2&gt;

&lt;p&gt;收听：&lt;a href=&quot;https://mp.weixin.qq.com/s/yzLQ4ABaiLrAu86pR6bktg&quot;&gt;Agentforce Specialist - Development Lifecycle &amp;amp; Multi-Agent 考点解析&lt;/a&gt;（17:49）&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Development Lifecycle（20%）&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Given a scenario, test an agent using Agentforce Testing Center.&lt;/li&gt;
  &lt;li&gt;Identify the considerations for deploying an agent from sandbox to production.&lt;/li&gt;
  &lt;li&gt;Explain the process for managing and monitoring agent adoption.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Multi-Agent Interoperability（5%）&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Explain the purpose of Model Context Protocol (MCP) and its use cases.&lt;/li&gt;
  &lt;li&gt;Explain the purpose of agent to agent protocol. Given a scenario, identify when it’s appropriate to use Agent API.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;旧版ai-specialist2024&quot;&gt;旧版：AI Specialist（2024）&lt;/h2&gt;

&lt;p&gt;Agentforce Specialist 的前身是 AI Specialist。2024 年 10 月做过两期，同样由 NotebookLM 生成，每期约 9 分钟。部分内容已经过时，仅供参考：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://mp.weixin.qq.com/s/_Q51oKZR-TEpqFObW4mGhg&quot;&gt;AI Specialist Certification - Einstein Trust Layer&lt;/a&gt;（8:50）&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://mp.weixin.qq.com/s/k3WpIUObacb86WzpAMjDnA&quot;&gt;AI Specialist Certification - Use Generative AI in CRM&lt;/a&gt;（8:48）&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;blockquote&gt;
  &lt;p&gt;音频首发于微信公众号「SalesforceTalk」。&lt;/p&gt;
&lt;/blockquote&gt;
</description>
        <pubDate>Thu, 25 Dec 2025 07:00:00 +0800</pubDate>
        <link>https://jairzh.com/blog/2025/12/25/agentforce-specialist-exam-audio-series</link>
        <guid isPermaLink="true">https://jairzh.com/blog/2025/12/25/agentforce-specialist-exam-audio-series</guid>
        
        <category>agentforce</category>
        
        <category>certification</category>
        
        
        <category>certification</category>
        
      </item>
    
      <item>
        <title>如何使用 Platform Event 处理 Trigger 中的复杂数据</title>
        <description>&lt;p&gt;如何使用单独的 Transaction （异步）来处理复杂的业务处理，包括耗时的计算和 Callout 操作，同时又能尽早的生成结果。避免使用 Scheduled 这种定时处理方式。&lt;/p&gt;

&lt;h2 id=&quot;trigger-中进行-callout&quot;&gt;Trigger 中进行 Callout&lt;/h2&gt;

&lt;p&gt;如果想在 Salesforce 的 trigger 中进行 callout，就需要使用 Future 或者 Queueable，但两个都有限制。包括：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;一个 Transaction 最多 50 次&lt;/li&gt;
  &lt;li&gt;每 24 小时 250,000 或者 License x 200 的数量，两者取最大值。Batch Apex, Queueable Apex, scheduled Apex, and future methods 共享。&lt;/li&gt;
  &lt;li&gt;Future 不能在异步方法中调用&lt;/li&gt;
  &lt;li&gt;Queueable 只能在异步方法中启动一个&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;基于上面的限制，因为 DML 最大数量是 10,000，trigger 默认的 size 是 200，所以 50 （10,000/200）个限制正常是没有问题的。但如果一个 Transaction 有下面的情况就会出问题：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;多于 50 个 DML，比如因为特殊情况，把 DML 放到了 For 循环中。&lt;/li&gt;
  &lt;li&gt;操作不同的对象，对象都有 trigger 并启动了 future 或者 queueable，数量不是整数。比如 4,100/200 = 21，5,900/200=30，21 + 30 就超出了&lt;/li&gt;
  &lt;li&gt;Trigger 的执行本身就是因为异步操作引起的，Future 就不能启动。或者 Queueable 不能大于一个。&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;使用-platform-event-方案&quot;&gt;使用 Platform Event 方案&lt;/h2&gt;

&lt;h3 id=&quot;platform-event-的特点&quot;&gt;Platform Event 的特点&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;同一时间只有一个在执行，多个会进行合并，方便并发处理。默认是 2000，可以指定。&lt;/li&gt;
  &lt;li&gt;Apex Trigger 订阅的话每小时有 250,000 个的限制，比异步 24 小时 25w 要多很多。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;platform-event-限制&quot;&gt;Platform Event 限制&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;因为同一时间只处理一个，所以属于单线程。如果处理一次需要 1s，这样的话，一天最多可以处理 86400 次的请求。&lt;/li&gt;
  &lt;li&gt;数据处理变成一个特定的 User，比如默认是 Automated Process。也可以指定特定的 User。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;platform-event-问题&quot;&gt;Platform Event 问题&lt;/h3&gt;

&lt;p&gt;Platform Event 可能会出现丢失的情况，虽然很罕见，但也需要注意。所以 Platform Events 需要是 stateless （无状态）, 这样可以接受丢失。无状态就意味着，需要有另外的 Object 进行储存，在要处理的对象上添加 Custom Field 进行标记。为了避免出现更新字段的时候并发问题，可以使用两个时间字段和一个 Formula 字段进行标记，当需要处理时间有值，处理时间没有值的时候，就可以将 Formula 设置成 True，在 SOQL 中进行查询，对数据进行处理。&lt;/p&gt;

&lt;h3 id=&quot;platform-event-方案总结&quot;&gt;Platform Event 方案总结&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;在 Trigger 中只发布一次 Platform Event，可以使用 Static 变量进行控制。作用就是启动一个异步线程，去对 Trigger 中的数据进行更复杂的处理。&lt;/li&gt;
  &lt;li&gt;Trigger 中需要对数据进行标记，方便 Platform Event 进行查询，获取要处理的数据。&lt;/li&gt;
  &lt;li&gt;Platform Event 使用 Formula 字段对数据查询，开始处理。对处理好的数据，再次更新，标记已经处理好。&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;参考&quot;&gt;参考&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/sirephil/sf-async-from-trigger&quot;&gt;Demo code&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.apexhours.com/governor-friendly-asynchronous-processing-from-triggers/&quot;&gt;Governor friendly asynchronous processing from triggers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;blockquote&gt;
  &lt;p&gt;本文首发于微信公众号「SalesforceTalk」，&lt;a href=&quot;https://mp.weixin.qq.com/s/jajqnXASQn5xWODaGP7e6Q&quot;&gt;阅读原文&lt;/a&gt;。&lt;/p&gt;
&lt;/blockquote&gt;
</description>
        <pubDate>Sun, 27 Aug 2023 18:03:37 +0800</pubDate>
        <link>https://jairzh.com/blog/2023/08/27/platform-event-for-complex-trigger-processing</link>
        <guid isPermaLink="true">https://jairzh.com/blog/2023/08/27/platform-event-for-complex-trigger-processing</guid>
        
        <category>platform-event</category>
        
        <category>trigger</category>
        
        
        <category>apex</category>
        
      </item>
    
      <item>
        <title>升级你的 Terminal，让 Salesforce 开发更高效</title>
        <description>&lt;p&gt;Salesforce 开始主推 Salesforce DX 的开发模式之后，用到 Salesforce CLI 的频率也越来越高了。&lt;/p&gt;

&lt;p&gt;使用 sfdx cli 除了 &lt;a href=&quot;https://forcedotcom.github.io/salesforcedx-vscode/&quot;&gt;Salesforce Extensions for VS Code&lt;/a&gt; 提供的 UI 封装之外，还有很多场景，需要在 Terminal 里直接执行相关命令。但 Mac 内置的 Terminal 并不是很好用，本篇给大家介绍一下，目前我在使用的一套方案，希望能帮助你提升生成效率。&lt;/p&gt;

&lt;h2 id=&quot;亮点&quot;&gt;亮点&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Terminal 中的 sfdx cli 自动提示&lt;/li&gt;
  &lt;li&gt;Terminal 自定义主题&lt;/li&gt;
  &lt;li&gt;Terminal 中显示 Git Branch 名字&lt;/li&gt;
  &lt;li&gt;Terminal 支持历史命令搜索&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;安装-homebrew&quot;&gt;安装 Homebrew&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://brew.sh/&quot;&gt;Homebrew&lt;/a&gt; 是 macOS(or Linux) 的一款 package 的管理工具，大部分和开发相关的 package 都可以使用它来安装和升级。&lt;/p&gt;

&lt;p&gt;复制下面这一行到 Terminal 中，回车确认进行安装。&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;/usr/bin/ruby &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;curl &lt;span class=&quot;nt&quot;&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/Homebrew/install/master/install&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;blockquote&gt;
  &lt;p&gt;Note: 安装 Homebrew 的时候会有一些依赖，在安装过程中会有提示，请仔细阅读具体的提示信息。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;安装-iterm2&quot;&gt;安装 iTerm2&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://www.iterm2.com/&quot;&gt;iTerm2&lt;/a&gt; 相对于 macOS 内置的 Terminal，提供了很多新的特性，大部分的开发人员都选择了 iTerm2 作为主要的执行命令行工具。可以直接到 iTerm2 官网进行&lt;a href=&quot;https://www.iterm2.com/downloads.html&quot;&gt;下载安装&lt;/a&gt;。可以顺便了解一下提供的&lt;a href=&quot;https://www.iterm2.com/features.html&quot;&gt;功能特性&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;安装-zsh&quot;&gt;安装 ZSH&lt;/h2&gt;

&lt;p&gt;Zsh 是一种以交互为目的设计的 shell script。macOS 内置了 Zsh，不过这里用 &lt;strong&gt;brew&lt;/strong&gt; 重新安装，升级到最新版本。&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;brew &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;zsh
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;安装-oh-my-zsh&quot;&gt;安装 Oh My Zsh&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/robbyrussell/oh-my-zsh&quot;&gt;Oh My Zsh&lt;/a&gt; 是一个管理 Zsh 配置的开源项目，提供了丰富的插件、主题和配置。&lt;/p&gt;

&lt;p&gt;安装方式&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sh &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;curl &lt;span class=&quot;nt&quot;&gt;-fsSL&lt;/span&gt; https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;安装过程中会提示选择 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zsh&lt;/code&gt; 作为默认的 shell script，选择 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Y&lt;/code&gt;。安装成功之后，重启 iTerm2 查看效果。&lt;/p&gt;

&lt;h2 id=&quot;修改-oh-my-zsh-的默认主题&quot;&gt;修改 Oh My Zsh 的默认主题&lt;/h2&gt;

&lt;p&gt;Oh My Zsh 提供了丰富的主题，具体可以在&lt;a href=&quot;https://github.com/robbyrussell/oh-my-zsh/wiki/Themes&quot;&gt;Github wiki 页面查看&lt;/a&gt;，找到适合自己的主题。推荐我正在使用的 &lt;a href=&quot;https://github.com/agnoster/agnoster-zsh-theme&quot;&gt;agnoster&lt;/a&gt;，主题提供：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://ethanschoonover.com/solarized/&quot;&gt;Solarized&lt;/a&gt; 配色&lt;/li&gt;
  &lt;li&gt;Git 信息提示&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;安装主题，需要修改 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.zshrc&lt;/code&gt;，使用默认编辑器打开配置文件。&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;open ~/.zshrc
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;修改 ZSH_THEME 这一行&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;ZSH_THEME=&quot;agnoster&quot;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;在 Terminal 的路径中隐藏 “user@hostname”，并控制路径的长度，可以在 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.zshrc&lt;/code&gt; 添加：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;prompt_context(){}

prompt_dir() {
  prompt_segment blue black &quot;%$(( $COLUMNS - 61 ))&amp;lt;...&amp;lt;%3~%&amp;lt;&amp;lt;&quot;
}
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;设置后的效果和更多配置方式可以点击这里查看&lt;a href=&quot;https://github.com/wesbos/Cobalt2-iterm/issues/15#issuecomment-224957918&quot;&gt;Trim long paths in prompt&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;安装字体&quot;&gt;安装字体&lt;/h2&gt;

&lt;p&gt;Oh My Zsh 的主题需要配合 &lt;a href=&quot;https://github.com/powerline/fonts&quot;&gt;powerline fonts&lt;/a&gt;，才可以保证主题内容的完整显示。&lt;/p&gt;

&lt;p&gt;使用下面方式安装&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# clone&lt;/span&gt;
git clone https://github.com/powerline/fonts.git &lt;span class=&quot;nt&quot;&gt;--depth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;1

&lt;span class=&quot;c&quot;&gt;# install&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;fonts
./install.sh

&lt;span class=&quot;c&quot;&gt;# clean-up a bit&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ..
&lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; fonts
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;安装成功后，修改 iTerm 的默认字体 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;iTerm2 &amp;gt; Preferences &amp;gt; Profiles &amp;gt; Text &amp;gt; Change Font.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/2019/07/15625000896823.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;字体可以选自己喜欢的，不过需要有 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;for Powerline&lt;/code&gt; 结尾的。&lt;/p&gt;

&lt;h2 id=&quot;修改-iterm2-的主题&quot;&gt;修改 iTerm2 的主题&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://iterm2colorschemes.com/&quot;&gt;Iterm2-color-schemes&lt;/a&gt; 在这个网站上下载主题包，然后安装下面方式启动主题：&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;iTerm2 &amp;gt; Preferences &amp;gt; Profile &amp;gt; Colors &amp;gt; Color Presets &amp;gt; Import&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/2019/07/15630709159672.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;上面几步配置好，重启 Terminal，就可以拥有一个全新的 Terminal 了 🎉&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/2019/07/15625003271577.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;安装-plugins&quot;&gt;安装 Plugins&lt;/h2&gt;

&lt;p&gt;Zsh 有丰富的插件，可以提供各种扩展，这里介绍几个插件：&lt;/p&gt;

&lt;h3 id=&quot;salesforce-cli-zsh-completion&quot;&gt;&lt;a href=&quot;https://github.com/wadewegner/salesforce-cli-zsh-completion&quot;&gt;salesforce-cli-zsh-completion&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Salesforce 团队成员写了一个 sfdx cli 的插件，可以实现自动提示，可以帮助我们在使用 sfdx cli 的时候快速找到需要的命令。&lt;/p&gt;

&lt;p&gt;安装方式&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git clone https://github.com/wadewegner/salesforce-cli-zsh-completion.git &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;ZSH_CUSTOM&lt;/span&gt;:&lt;span class=&quot;p&quot;&gt;=~/.oh-my-zsh/custom&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;/plugins/salesforce-cli-zsh-completion
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;编辑 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.zshrc&lt;/code&gt;，添加 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;salesforce-cli-zsh-completion&lt;/code&gt; 到 plugins 中&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;# ~/.zshrc
plugins=(salesforce-cli-zsh-completion)

source $ZSH/oh-my-zsh.sh

autoload -U compinit &amp;amp;&amp;amp; compinit
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;执行下面的命令重新加载配置&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt; ~/.zhrc
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cd&lt;/code&gt; 到一个 sfdx cli 初始化的项目，然后输入 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sfdx&lt;/code&gt;，点击两次 tab 键，就会有提示了，enjoy it！&lt;/p&gt;

&lt;h3 id=&quot;推荐其他插件&quot;&gt;推荐其他插件&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/zsh-users/zsh-syntax-highlighting&quot;&gt;zsh-syntax-highlighting&lt;/a&gt;: This package provides syntax highlighting for the shell zsh. It enables highlighting of commands whilst they are typed at a zsh prompt into an interactive terminal. This helps in reviewing commands before running them, particularly in catching syntax errors.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/zsh-users/zsh-autosuggestions&quot;&gt;zsh-autosuggestions&lt;/a&gt;: It suggests commands as you type based on history and completions.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins#git&quot;&gt;git&lt;/a&gt;: Adds a lot of git aliases and functions for day-to-day git operations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;插件安装配置好之后，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.zshrc&lt;/code&gt; 文件中的 plugins:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;plugins=(
  git
  salesforce-cli-zsh-completion
  zsh-autosuggestions
  zsh-syntax-highlighting
)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;快捷键&quot;&gt;快捷键&lt;/h2&gt;

&lt;p&gt;在命令行操作的时候，因为对光标的支持并不是很好，可以掌握一些基本的快捷键，帮助你快速的完成一些操作。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl + a&lt;/code&gt;: 移动到当前行的最前面&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl + e&lt;/code&gt;: 移动到当前行的最后面&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl + r&lt;/code&gt;: 搜索之前命令&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl + w&lt;/code&gt;: 删除光标前的单词&lt;/li&gt;
  &lt;li&gt;在 Tab 之间切换: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Cmd + →&lt;/code&gt; 和 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Cmd + ←&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Cmd + D&lt;/code&gt; 打开一个新的 Pane&lt;/li&gt;
  &lt;li&gt;在 Pane 之间切换 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Cmd + ]&lt;/code&gt; 和 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Cmd + [&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;配置 iTerm 的全局切换 hotkey:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;iTerm2 &amp;gt; Preferences &amp;gt; Keys &amp;gt; Show/hide iTerm with a system-wide hotkey&lt;/code&gt; 指定一个你想使用的一个快捷键，比如 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl + space&lt;/code&gt;。&lt;/p&gt;

&lt;h2 id=&quot;别名-aliases&quot;&gt;别名 Aliases&lt;/h2&gt;

&lt;p&gt;添加一些 alias 可以让你更方便的输入一些你常用的命名或者命令组合。配置方式很简单，只需要在 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.zshrc&lt;/code&gt; 中添加就可以了。比如：&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;sfpush&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;sfdx force:source:push --json --loglevel fatal&quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;另外 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;oh-my-zsh&lt;/code&gt; 内置了很多 alias，比如 &lt;a href=&quot;https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/git/git.plugin.zsh&quot;&gt;git alias&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;vs-code-配置&quot;&gt;VS Code 配置&lt;/h2&gt;

&lt;p&gt;在 Settings 里加入下面两行，让上面的配置在 VS Code 的 Terminal 生效。&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nl&quot;&gt;&quot;terminal.integrated.fontFamily&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Source Code Pro for Powerline&quot;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;terminal.integrated.shell.osx&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/bin/zsh&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;参考&quot;&gt;参考&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.freecodecamp.org/news/how-to-configure-your-macos-terminal-with-zsh-like-a-pro-c0ab3f3c1156/&quot;&gt;How to Configure your macOs Terminal with Zsh like a Pro&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://medium.com/@sahanarajasekar/5-ways-to-upgrade-your-terminal-2fb8ab447949&quot;&gt;5 ways to upgrade your Terminal&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
        <pubDate>Sun, 14 Jul 2019 08:25:29 +0800</pubDate>
        <link>https://jairzh.com/blog/2019/07/14/upgrade-your-terminal-for-salesforce-development</link>
        <guid isPermaLink="true">https://jairzh.com/blog/2019/07/14/upgrade-your-terminal-for-salesforce-development</guid>
        
        <category>terminal</category>
        
        
        <category>tool</category>
        
      </item>
    
      <item>
        <title>迁移到 Salesforce Extensions for Visual Studio Code</title>
        <description>&lt;p&gt;Salesforce 新推出的 IDE 经过不断的迭代升级之后，现在已经很成熟，所有现在完全可以从 Sublime 或者 Eclipse 迁移到 &lt;a href=&quot;https://forcedotcom.github.io/salesforcedx-vscode/articles/user-guide/org-development-model&quot;&gt;Salesforce Extensions for Visual Studio Code&lt;/a&gt;。&lt;/p&gt;

&lt;h3 id=&quot;安装-salesforce-extensions-for-vs-code&quot;&gt;安装 Salesforce Extensions for VS Code&lt;/h3&gt;

&lt;p&gt;安装步骤可以参考官方文档 &lt;a href=&quot;https://forcedotcom.github.io/salesforcedx-vscode/articles/getting-started/install&quot;&gt;Install Salesforce Extensions for VS Code&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;vs-code-的优势&quot;&gt;VS Code 的优势&lt;/h3&gt;

&lt;p&gt;VS Code 的插件是官方在维护，这里列几点和其他 IDE 相比的优势：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;官方团队维护，更新速度快，不断会有新功能的推出&lt;/li&gt;
  &lt;li&gt;强大的智能提示&lt;/li&gt;
  &lt;li&gt;运行测试代码方便&lt;/li&gt;
  &lt;li&gt;支持所有 Salesforce 相关的开发，包括 Apex, VF, Aura 和 LWC&lt;/li&gt;
  &lt;li&gt;支持两种开发模式，Org Development 和 Package Development Model&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;开发新项目&quot;&gt;开发新项目&lt;/h3&gt;

&lt;p&gt;如果是新项目，就可以直接使用 Salesforce 提供的文档进行开发就可以了，具体可以看这里：&lt;a href=&quot;https://forcedotcom.github.io/salesforcedx-vscode&quot;&gt;https://forcedotcom.github.io/salesforcedx-vscode&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;迁移旧项目&quot;&gt;迁移旧项目&lt;/h3&gt;

&lt;p&gt;很多现有项目，基本在使用 Sublime 或者 Eclipse 开发，这里提供一下具体的迁移步骤:&lt;/p&gt;

&lt;p&gt;1 打开 VS Code，然后 打开 command palette (press Ctrl+Shift+P on Windows or Linux, or Cmd+Shift+P on macOS) 运行 &lt;strong&gt;SFDX: Create Project with manifest&lt;/strong&gt;，输入和旧项目相同的名字，然后找到原来项目的上级目录，回车确认，等待成功之后，会把原来的项目初始化成一个 VS Code 的项目。&lt;/p&gt;

&lt;p&gt;2 更新 &lt;strong&gt;.gitignore&lt;/strong&gt; 文件，忽略 VS Code 相关不需要提交的文件和文件夹。&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;# Ignore OS system files that are usually auto-added to directories
[Tt]humbs.db
.DS_Store

# Ignore Salesforce DX config files
.sfdx
.salesforce

# Ignore VSCode config files
.vscode
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;保存之后，git 提交一下。&lt;/p&gt;

&lt;p&gt;3 执行下面的命令转化 Source format 并且保留 git 的提交历史。&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;git config merge.renameLimit 999999
sfdx force:mdapi:convert &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; src &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; src2
&lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; src
&lt;span class=&quot;nb&quot;&gt;mv &lt;/span&gt;src2 src
git add &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt;
git commit &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Converted from metadata to source format&quot;&lt;/span&gt;
git config &lt;span class=&quot;nt&quot;&gt;--unset&lt;/span&gt; merge.renameLimit &lt;span class=&quot;c&quot;&gt;# Return the git config option to the default&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;4 打开 command palette 执行 &lt;strong&gt;SFDX: Authorize an Org&lt;/strong&gt;，登陆一个 org，然后就可以正常开发了。&lt;/p&gt;

&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://forcedotcom.github.io/salesforcedx-vscode/articles/user-guide/org-development-model&quot;&gt;Org Development Model with VS Code&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://ntotten.com/2018/05/11/convert-metadata-to-source-format-while-maintain-git-history/&quot;&gt;Converting Salesforce Metadata to Source Format While Maintain Git History&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
        <pubDate>Mon, 22 Apr 2019 08:25:29 +0800</pubDate>
        <link>https://jairzh.com/blog/2019/04/22/migrate-to-salesforce-extensions-for-visual-studio-code</link>
        <guid isPermaLink="true">https://jairzh.com/blog/2019/04/22/migrate-to-salesforce-extensions-for-visual-studio-code</guid>
        
        <category>vs-code</category>
        
        <category>apex</category>
        
        
        <category>tool</category>
        
      </item>
    
      <item>
        <title>Debug Lightning Web Components</title>
        <description>&lt;h2 id=&quot;enable-debug-model&quot;&gt;Enable Debug Model&lt;/h2&gt;

&lt;p&gt;LWC 的 JS code 默认是为了加载速度的提升，默认是 minified 的文件，不利于阅读和调试。所有在开发的时候，可以打开 &lt;strong&gt;Debug Mode&lt;/strong&gt;。&lt;/p&gt;

&lt;p&gt;To enable debug mode for users in your org:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;In Salesforce, from &lt;strong&gt;Setup&lt;/strong&gt;, enter &lt;strong&gt;Debug Mode&lt;/strong&gt; in the Quick Find box, then select &lt;strong&gt;Debug Mode Users&lt;/strong&gt;.&lt;/li&gt;
  &lt;li&gt;Enable the selection checkbox next to users for whom you want to enable debug mode.&lt;/li&gt;
  &lt;li&gt;Click &lt;strong&gt;Enable&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;debug-using-chrome-devtools&quot;&gt;Debug Using Chrome DevTools&lt;/h2&gt;

&lt;p&gt;开启 Debug Mode 之后，就可以使用 Chrome 的 DevTools 进行断点调试。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/2019/03/15522253795992.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;具体方式：&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;打开包含要调试的 Component 页面，鼠标右键或者快捷键（Control-Shift-I or Option-Command-I) 打开 DevTools&lt;/li&gt;
  &lt;li&gt;点击 Sources，在左侧目录找到对应的文件&lt;/li&gt;
  &lt;li&gt;在中间部分，相应的 JS 行号上使用鼠标点击设置断点&lt;/li&gt;
  &lt;li&gt;重新刷新页面，页面会停留在断点处，然后可以查看相关的信息&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;config-chrome-devtools&quot;&gt;Config Chrome DevTools&lt;/h2&gt;

&lt;h3 id=&quot;blackbox-javascript-source-files&quot;&gt;Blackbox JavaScript Source Files&lt;/h3&gt;

&lt;p&gt;在使用 Chrome DevTools 进行调试的时候，在一行一行查看你的代码的时候，有的时候会进入到你不想查看的代码中（比如 Salesforce 标准的 components 或者第三方库）。Chrome 提供了一个配置，可以屏蔽掉这些不想进入的 js 文件或者目录中。&lt;/p&gt;

&lt;h4 id=&quot;屏蔽方式&quot;&gt;屏蔽方式&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;在 Settings -&amp;gt; Blackboxing 加入下面的正则，屏蔽 Salesforce 标准库的 js 文件。&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;/aura_prod.*\.js$
\/components\/.*.js$
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/2019/03/15522270209681.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;JS 源文件菜单&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;在调试的过程中，可以在 js 文件上，点击右键，在菜单中选择 &lt;strong&gt;Blackbox script&lt;/strong&gt; 里屏蔽当前文件。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/2019/03/15522274057045.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;enable-custom-formatters&quot;&gt;Enable custom formatters&lt;/h3&gt;

&lt;p&gt;DevTools 默认情况下没有启用 Custom Formatters，这样的话在调试的过程中，属性会显示成 Proxy，不方便阅读和调试。在 Settings -&amp;gt; Preferences 中选中 &lt;strong&gt;Enable custom formatters&lt;/strong&gt;，就可以直接查看当前变量对应的值。&lt;/p&gt;

&lt;p&gt;开启前：&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/2019/03/15522289186810.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;开启后：&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/2019/03/Screen-Shot-2019-03-10-at-10.38.54-PM.png&quot; alt=&quot;Screen Shot 2019-03-10 at 10.38.54 P&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;resources&quot;&gt;Resources&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.debug_intro&quot;&gt;Debug Lightning Web Components&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://youtu.be/0B37nkNSVtg&quot;&gt;Lightning Web Components: Debug Lightning Web Components&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://developer.chrome.com/devtools/docs/blackboxing&quot;&gt;Blackbox JavaScript Source Files&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
        <pubDate>Sat, 09 Mar 2019 08:25:29 +0800</pubDate>
        <link>https://jairzh.com/blog/2019/03/09/debug-lightning-web-components</link>
        <guid isPermaLink="true">https://jairzh.com/blog/2019/03/09/debug-lightning-web-components</guid>
        
        
        <category>lwc</category>
        
      </item>
    
  </channel>
</rss>
