mcpField
F
flow-orchestrator-2025

flow-orchestrator-2025

github.com/josiahsiegel生产力59161 次安装19 周前更新
代码仓库

关于 flow-orchestrator-2025

面向无需 Apex 构建多用户业务流程的团队,介绍 Salesforce Flow Orchestrator。内容涵盖分阶段工作流,以及用户任务、后台自动化、审批和故障处理的组合方式。

主要功能

  1. 01多用户分阶段工作流
  2. 02交互式与后台步骤
  3. 03按条件执行阶段
  4. 04带重试的故障路径
  5. 05进度跟踪与监控

适用场景

  1. 01协调跨团队员工入职
  2. 02跨职能处理报价审批
  3. 03按级别升级支持案例
  4. 04处理配置步骤失败后的恢复

安装

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

$npx skills add https://github.com/josiahsiegel/claude-plugin-marketplace --skill flow-orchestrator-2025

安装后在 Claude Code 中输入/flow-orchestrator-2025确认已加载。

附带文件references/advanced-patterns-monitoring.md

详细介绍

🚨 关键准则

Windows 文件路径要求

强制要求:在 Windows 上始终使用反斜杠表示文件路径

在 Windows 上使用 Edit 或 Write 工具时,必须在文件路径中使用反斜杠(\),而非正斜杠(/)。

示例:

  • ❌ 错误:D:/repos/project/file.tsx
  • ✅ 正确:D:\repos\project\file.tsx

适用于:

  • Edit 工具的 file_path 参数
  • Write 工具的 file_path 参数
  • Windows 系统上的所有文件操作
文档编写准则

除非用户明确要求,否则绝不创建新的文档文件。

  • 优先事项:更新现有的 README.md 文件,而不是创建新的文档
  • 保持仓库整洁:保持仓库根目录整洁——除非用户另有要求,否则只保留 README.md
  • 风格:文档应简洁、直接、专业,避免使用 AI 生成的语气
  • 用户偏好:只有用户明确要求编写文档时,才创建其他 .md 文件

Salesforce Flow Orchestrator(2025)

什么是 Flow Orchestrator?

Flow Orchestrator 可在无需编写代码的情况下协调涉及多用户、多步骤、多阶段的业务流程。不同用户会在同一工作流中依次完成任务,并使用内置审批、条件逻辑和错误处理功能。

主要功能:

  • 多用户工作流:在不同阶段将任务分配给不同用户或团队
  • 基于阶段的执行:将工作划分为逻辑阶段
  • 后台自动化:将用户任务与自动化步骤结合
  • 可视化进度跟踪:用户可以查看自己在工作流中的进度
  • 故障路径:优雅地处理错误(Summer '25)
  • 无需代码:无需 Apex 即可构建复杂流程

何时使用 Flow Orchestrator

用例使用 Flow Orchestrator?原因
员工入职(人力资源 → IT → 经理)✅ 是涉及多用户和顺序阶段
报价到收款(销售 → 财务 → 运营)✅ 是跨职能审批流程
案例升级(L1 → L2 → L3 支持)✅ 是分级分配,并设有 SLA
简单记录自动化(创建/更新)❌ 否使用 Record-Triggered Flow
单用户流程❌ 否使用 Screen Flow
批量数据处理❌ 否使用 Scheduled Flow 或 Apex Batch

编排架构

Orchestration = Stages → Steps → Background Automations

Stage 1: "HR Review"
├─ Step 1.1: Interactive Step (HR Manager reviews)
├─ Step 1.2: Background Automation (create records)
└─ Decision: Approved? → Next Stage : End

Stage 2: "IT Provisioning"
├─ Step 2.1: Interactive Step (IT assigns equipment)
├─ Step 2.2: Background Automation (provision accounts)
└─ Step 2.3: Interactive Step (IT confirms completion)

Stage 3: "Manager Onboarding"
├─ Step 3.1: Interactive Step (Manager schedules 1:1)
└─ Step 3.2: Background Automation (send welcome email)

构建编排(分步说明)

示例:员工入职流程

要求:

  • 人力资源部门审核新员工文档 → 批准/拒绝
  • 如果获得批准,IT 部门配置账户和设备
  • 经理安排入职首日并分配导师
  • 系统在每个阶段发送通知
步骤 1:创建编排
Setup → Flows → New Flow → Orchestration
Name: Employee_Onboarding
Object: Employee__c (custom object)
Trigger: Record Created, Status = 'Pending Onboarding'
步骤 2:设计阶段

阶段 1:人力资源部门审核文档

Stage Name: HR_Document_Review
Stage Description: HR verifies employee documentation
Run Mode: One at a Time (sequential)

Step 1.1 (Interactive):
- Name: Review_Documents
- Assigned To: Queue "HR_Onboarding_Queue"
- Due Date: 2 days from start
- Screen Flow: HR_Document_Review_Screen
- Inputs: Employee__c.Id

Step 1.2 (Background - Decision):
- If HR_Approved = true → Next Stage
- If HR_Approved = false → End + Send Rejection Email

阶段 2:IT 部门配置

Stage Name: IT_Provisioning
Condition: Runs only if Stage 1 approved

Step 2.1 (Interactive):
- Name: Assign_Equipment
- Assigned To: Queue "IT_Provisioning_Queue"
- Due Date: 3 days from stage start
- Screen Flow: IT_Equipment_Assignment
- Inputs: Employee__c.Id

Step 2.2 (Background):
- Name: Create_AD_Account
- Autolaunched Flow: Create_Active_Directory_Account
- Inputs: Employee__c.Email, Employee__c.FirstName

Step 2.3 (Background):
- Name: Send_IT_Confirmation
- Action: Send Email Template
- Recipient: Employee__c.Email
- Template: Welcome_Email

阶段 3:经理安排

Stage Name: Manager_Setup
Depends On: Stage 2 complete

Step 3.1 (Interactive):
- Name: Schedule_First_Day
- Assigned To: Employee__c.Manager__c
- Due Date: 1 day from stage start
- Screen Flow: Manager_Onboarding_Tasks

Step 3.2 (Background):
- Name: Update_Status
- Record Update: Employee__c.Status = 'Onboarding Complete'
步骤 3:实现故障路径(Summer '25)

IT 配置失败时的故障路径:

If Step 2.2 (Create_AD_Account) fails:
├─ Retry Step (1 attempt after 10 minutes)
├─ If still fails:
│  ├─ Send email to IT Manager with error details
│  ├─ Create Task for manual provisioning
│  └─ Assign Interactive Step to IT Manager for resolution
└─ Continue to Stage 3 (don't block entire process)

配置:

Step 2.2: Create_AD_Account
├─ Fault Path Enabled: true
├─ Retry Attempts: 1
├─ Retry Delay: 10 minutes
└─ On Final Failure:
   ├─ Create Task
   │  ├─ Subject: "Manual AD Account Creation Needed"
   │  ├─ Assigned To: IT_Manager_Queue
   │  └─ Priority: High
   └─ Send Email Notification
      ├─ Template: IT_Provisioning_Failure
      └─ Recipients: IT Managers

交互步骤与后台步骤

交互步骤

适用场景:需要人工判断或输入的操作

Interactive Step Configuration:
├─ Screen Flow: Define UI for user input
├─ Assigned To: User, Queue, or Role
├─ Due Date: Formula (TODAY() + 2 for 2 days)
├─ Instructions: What user should do
├─ Input Variables: Data passed to screen flow
└─ Output Variables: Data returned from user

Screen Flow 示例(人力资源审核):

Screen: Review Documents
├─ Display: Employee Name, Position, Documents Uploaded
├─ Input: Radio Button (Approve / Reject)
├─ Input: Text Area (Comments - required if reject)
└─ Action: Save & Submit

Output Variables:
- HR_Approved (Boolean)
- HR_Comments (Text)
后台步骤

适用场景:无需用户交互的自动化操作

Background Step Types:
├─ Autolaunched Flow: Call another flow
├─ Apex Action: Invoke Apex method
├─ Send Email: Email template or custom
├─ Post to Chatter: Notify users
├─ Create Records: DML operations
├─ Update Records: Field updates
├─ External Service: REST callout
└─ Wait: Pause for duration or until condition

高级模式与监控

高级 Flow Orchestrator 设计(并行审批、条件分支、重试/升级、记录触发的编排、外部集成交接),以及监控、报告和运营仪表板,请参阅 references/advanced-patterns-monitoring.md。对于复杂的多阶段实施和生产环境可观测性,请加载该参考文档。

与其他功能集成

模式:编排 + 审批流程
Stage 2: Manager Approval
├─ Step 2.1 (Interactive): Manager reviews
│  └─ Screen Flow with Approve/Reject buttons
├─ Background Automation: Update approval status
└─ If Approved: Proceed to Stage 3
   If Rejected: Send rejection email, End orchestration
模式:编排 + Platform Events

在阶段转换时发布事件:

trigger OrchestrationStageTrigger on FlowOrchestrationStageInstance (after insert, after update) {
    List<OrchestrationStageEvent__e> events = new List<OrchestrationStageEvent__e>();

    for (FlowOrchestrationStageInstance stage : Trigger.new) {
        if (stage.Status == 'Completed') {
            events.add(new OrchestrationStageEvent__e(
                OrchestrationId__c = stage.OrchestrationInstanceId,
                StageName__c = stage.StepDefinitionName,
                CompletedDate__c = System.now()
            ));
        }
    }

    if (!events.isEmpty()) {
        EventBus.publish(events);
    }
}

从外部订阅:

// External system tracks orchestration progress
client.subscribe('/event/OrchestrationStageEvent__e', (message) => {
    const { OrchestrationId__c, StageName__c } = message.data.payload;
    console.log(`Stage ${StageName__c} completed for ${OrchestrationId__c}`);

    // Update external dashboard
    updateOrchestrationStatus(OrchestrationId__c, StageName__c);
});
模式:编排 + Agentforce

由 AI Agent 处理特定步骤:

Stage 2: Document Verification
├─ Step 2.1 (Background): AI agent verifies documents
│  └─ Agentforce Action: Verify_Document_Compliance
│     - Uses Einstein OCR to extract text
│     - Uses LLM to validate against compliance rules
│     - Returns: Compliant (true/false) + Confidence score
├─ Decision: If confidence < 90% → Human review
└─ Step 2.2 (Interactive - Conditional): Human verifies (if AI uncertain)

最佳实践

设计
  • 构建前先规划阶段:在纸上或白板上绘制工作流
  • 每个编排对应一个业务流程:不要合并无关流程
  • 阶段/步骤名称应有意义:使用业务术语,而非技术术语
  • 说明清晰:明确告知用户每个步骤要做什么
  • 设置适当的截止日期:在紧迫性与实际时间安排之间取得平衡
性能
  • 尽量减少每个阶段的步骤数:每个阶段少于 10 个步骤,以便于维护
  • 避免不必要的等待:只有确实需要时才暂停
  • 批量处理后台自动化:高效处理多条记录
  • 合理使用决策逻辑:通过条件跳过不必要的阶段
  • 监控正在运行的编排:定期归档已完成的编排
错误处理
  • 始终实现故障路径(Summer '25):不要让失败阻塞整个流程
  • 重试暂时性错误:例如网络问题、临时 API 故障
  • 升级永久性错误:创建任务以便人工干预
  • 记录失败:跟踪出错原因以便排查问题
  • 测试错误场景:在沙盒中主动触发故障
安全性
  • 遵守共享规则:编排调用的 Apex 中使用 "with sharing"
  • 字段级安全性:确保用户有权访问屏幕流中的字段
  • 队列成员资格:确认队列中的用户拥有必要的权限
  • 敏感数据:在屏幕流和工作项中遮盖或加密 PII
用户体验
  • 适配移动设备的屏幕:许多用户使用移动设备工作
  • 进度指示器:向用户显示当前流程进度
  • 明确后续步骤:始终告知用户完成某个步骤后会发生什么
  • 及时通知:在截止日期前发送提醒
  • 提交反馈:确认操作已成功

故障排除

常见问题

问题 1:用户看不到工作项

Causes:
- User not in assigned queue
- User lacks permission to object
- Filter criteria on view excludes item

Solution:
1. Check queue membership: Setup → Queues
2. Verify object permissions: User profile/permission set
3. Review work item list view filters

问题 2:后台步骤无提示地失败

Causes:
- Apex error in called flow/action
- Required field missing
- Governor limit exceeded

Solution:
1. Enable debug logs: Setup → Debug Logs
2. Check Flow error emails: Setup → Process Automation Settings
3. Implement fault path to catch and handle errors

问题 3:编排未触发

Causes:
- Trigger criteria not met
- Record not updated properly
- Orchestration inactive

Solution:
1. Verify record meets entry criteria
2. Check orchestration activation status
3. Review audit trail for record updates
使用 Apex 调试
// Query orchestration details for debugging
public class OrchestrationDebugger {
    public static void debugOrchestration(Id recordId) {
        // Find orchestration instances for record
        List<FlowOrchestrationInstance> instances = [
            SELECT Id, Label, Status, CreatedDate
            FROM FlowOrchestrationInstance
            WHERE RelatedRecordId = :recordId
            ORDER BY CreatedDate DESC
        ];

        for (FlowOrchestrationInstance instance : instances) {
            System.debug('Orchestration: ' + instance.Label);
            System.debug('Status: ' + instance.Status);

            // Get work items
            List<FlowOrchestrationWorkItem> items = [
                SELECT Id, Label, Status, AssignedToId, DueDate
                FROM FlowOrchestrationWorkItem
                WHERE OrchestrationInstanceId = :instance.Id
                ORDER BY CreatedDate
            ];

            for (FlowOrchestrationWorkItem item : items) {
                System.debug('  Step: ' + item.Label + ', Status: ' + item.Status);
            }
        }
    }
}

定价与可用性

  • 版本:Enterprise、Performance、Unlimited、Developer
  • 包含的运行次数:每年 600 次编排运行(免费)
  • 额外运行次数:高用量时可按批次购买
  • 所需权限:
    • 创建/编辑:Manage Flows 权限
    • 查看:在 Automation App 中查看编排(Winter '26)
    • 批准流:Approval Designer 系统权限(Winter '26)

资源

从 Process Builder 迁移

Process Builder → Flow Orchestrator:

Process Builder supports only simple automation
Flow Orchestrator adds:
- Multi-user coordination
- Interactive steps
- Stage-based organization
- Visual progress tracking
- Fault handling

When to migrate:
- Process involves multiple users
- Need stage-based workflow
- Want user interface for steps
- Require better error handling

Flow Orchestrator 可将复杂的跨职能业务流程转变为可视化、易管理的工作流,并支持在整个组织中扩展。

评论

支持 Markdown