life-sciences-kam-coordinate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLife Sciences Cloud KAM End-to-End Orchestrator
Life Sciences Cloud KAM端到端编排器
Runs the complete Life Sciences Cloud setup for a key account management (KAM) user as six stages in strict sequence, gating each on the previous stage's success. Each stage delegates to a child skill or reference workflow (see Execution Order).
按严格顺序运行针对关键客户管理(KAM)用户的完整Life Sciences Cloud设置流程,分为六个阶段,每个阶段的推进均依赖于前一阶段的成功。每个阶段会委托给子Skill或参考工作流(详见执行顺序)。
Scope Guard (evaluate FIRST)
范围校验(优先执行)
Serve only requests for the full end-to-end LSC setup for a KAM user. A single stage/phase/step is never invokable here — never silently expand a partial ask into the whole flow. Before any work:
- Field sales rep persona (not KAM) → redirect to ; stop.
life-sciences-fieldsalesrep-coordinate - Unrelated to LSC setup (at start or mid-run) → do not attempt it; say you did not understand and show what you can help with (full end-to-end LSC KAM setup, or standalone /
life-sciences-prerequisites-validate); stop.life-sciences-territory-configure - Single stage with its own standalone skill — prerequisites (1) or territory config (3) → redirect to that skill; stop.
- Single stage with no standalone skill — config deploy (2), participant role/sprint (4), data and plan templates (5), user provisioning (6) → explain these run only inside the full flow; stop. Do not launch the full flow unless the user then asks.
Continue only for the complete end-to-end KAM setup: the full flow in order with gates, each stage's work delegated to child skills / reference files.
仅处理针对KAM用户的完整LSC端到端设置请求。绝不允许单独调用单个阶段/环节/步骤——切勿将部分请求自动扩展为完整流程。在开展任何工作前:
- 现场销售代表角色(非KAM)→ 重定向至;终止流程。
life-sciences-fieldsalesrep-coordinate - 与LSC设置无关(流程启动时或运行中)→ 请勿尝试执行,告知用户无法理解请求并展示可提供的帮助(完整LSC KAM端到端设置,或独立的/
life-sciences-prerequisites-validate);终止流程。life-sciences-territory-configure - 拥有独立Skill的单个阶段——先决条件(1)或区域配置(3)→ 重定向至对应Skill;终止流程。
- 无独立Skill的单个阶段——配置部署(2)、参与者角色/冲刺(4)、数据与计划模板(5)、用户配置(6)→ 说明这些仅能在完整流程内运行;终止流程。除非用户后续明确要求,否则不得启动完整流程。
仅在用户请求完整KAM端到端设置时继续执行:按顺序运行带依赖校验的完整流程,每个阶段的工作委托给子Skill/参考文件。
Required Inputs
必要输入
- Target org: the org to deploy to — selected by the user from connected orgs or a freshly authenticated org (Phase 0). Never assume a default org silently; the user confirms or selects it before any stage runs.
- 目标组织:要部署的组织——由用户从已连接组织或新认证的组织中选择(第0阶段)。切勿默认使用某个组织;在任何阶段运行前,需由用户确认或选择目标组织。
Execution Order (MANDATORY)
执行顺序(强制要求)
Terminology: Stage = one of the 6 units of work, each delegated to a child skill/reference; Phase = a named group inside a stage; Step = an atomic action inside a phase.
Run in this order, each gated on the previous (dependency diagram in ):
references/orchestration-flow.md| # | Stage | Runs | Gate (must pass to advance) | Output |
|---|---|---|---|---|
| — | Setup: download | — | Folder present (MANDATORY — hard stop) | Shared source folder in CWD |
| 1 | Prerequisites Validation | | All prerequisites PASS | Org confirmed ready |
| 2 | Starter Config Deploy | | 13 deploy steps + KAM config records succeed | LSC Custom Profile + KAM/Sprint settings |
| 3 | Territory Configuration | | Territory model Active + L3 territory | Level-3 territory ID + name |
| 4 | Participant Role & Sprint | | Participant role + sprint created | Role + Sprint IDs |
| 5 | KAM Data & Plan Templates | | Account/HCP/product/territory data created + goals, template (Final), items, assignment created + goals/template/PATI shared to the leaf territory | Account + product master data + published ActionPlanTemplate |
| 6 | KAM User Provisioning | | User created, permsets + territory assigned; metadata cache generated | KAM username |
术语定义: Stage(阶段) = 6个工作单元之一,每个单元委托给子Skill/参考文件;Phase(环节) = 阶段内的命名分组;Step(步骤) = 环节内的原子操作。
按以下顺序运行,每个阶段均依赖前一阶段的成功(依赖关系图见):
references/orchestration-flow.md| # | 阶段 | 运行内容 | 校验条件(必须通过才能推进) | 输出 |
|---|---|---|---|---|
| — | 准备工作:下载 | — | 文件夹已存在(强制要求——未满足则终止) | 当前工作目录下的共享源文件夹 |
| 1 | 先决条件验证 | | 所有先决条件通过 | 确认组织已就绪 |
| 2 | 初始配置部署 | | 13个部署步骤 + KAM配置记录执行成功 | LSC自定义配置文件 + KAM/冲刺设置 |
| 3 | 区域配置 | | 区域模型已激活 + 三级区域存在 | 三级区域ID + 名称 |
| 4 | 参与者角色与冲刺创建 | | 参与者角色 + 冲刺已创建 | 角色 + 冲刺ID |
| 5 | KAM数据与计划模板创建 | | 客户/HCP/产品/区域数据已创建 + 目标、模板(最终版)、任务、分配已创建 + 目标/模板/PATI已共享至叶子区域 | 客户 + 产品主数据 + 已发布的ActionPlanTemplate |
| 6 | KAM用户配置 | | 用户已创建,权限集 + 区域已分配;元数据缓存已生成 | KAM用户名 |
Workflow
工作流
Phase 0 — Org Selection (MANDATORY, runs first)
第0环节——组织选择(强制要求,优先运行)
Establish which org to use every time — never silently reuse the default org.
- List connected orgs with , then present the authenticated (non-expired) orgs as a numbered list (alias, username, org type, default marker), plus an option N to log in to a fresh org.
sf org list --json - Ask the user to choose a number or N.
- Handle the selection:
- Existing org → capture its username/alias as the target org.
- Fresh org (N) → ask for the login URL (,
https://login.salesforce.com, or a My Domain URL) and an alias, then run the login command yourself:https://test.salesforce.com. Do not hand the command to the user to run — execute it directly. It opens a browser on the user's machine for them to complete the login interactively; the command then returns. After it finishes, re-runsf org login web --instance-url <url> --alias <alias> --set-defaultto confirm.sf org list --json
- Confirm the target org back to the user and store it in .
OrchestrationState.targetOrg
Ifreturns no authenticated orgs, go straight to the fresh-org login (option N).sf org list
每次都要确认使用哪个组织——切勿默认复用之前的组织。
- 列出已连接组织:执行,然后将已认证(未过期)的组织以编号列表形式展示(别名、用户名、组织类型、默认标记),同时提供选项N用于登录新组织。
sf org list --json - 请求用户选择:让用户选择编号或N。
- 处理选择:
- 现有组织 → 捕获其用户名/别名作为目标组织。
- 新组织(N) → 请求登录URL(、
https://login.salesforce.com或自定义域名URL)和别名,然后自行运行登录命令:https://test.salesforce.com。请勿让用户自行运行命令——直接执行该命令。命令会在用户机器上打开浏览器,供用户完成交互式登录;登录完成后命令返回。执行完成后,重新运行sf org login web --instance-url <url> --alias <alias> --set-default确认登录成功。sf org list --json
- 向用户确认目标组织并将其存储在中。
OrchestrationState.targetOrg
如果未返回任何已认证组织,直接进入新组织登录流程(选项N)。sf org list
Phase 1 — Introduction and Confirmation
第1环节——介绍与确认
-
Present the workflow to the user — a "Life Sciences Cloud — Full KAM Setup Workflow" header, the target org, and the 6 stages in order with a one-line summary each: (1) Validate Prerequisites; (2) Deploy Starter Configuration (objects, profiles, config records incl. KAM & Sprint settings, layouts, flexipages); (3) Configure Territories; (4) Create Participant Role & Sprint; (5) Create KAM Data & Plan Templates (account, provider, product, territory data + goals, tasks, measures, published action plan template); (6) Provision KAM User (profile/permsets/territory + mobile metadata cache).
-
Ask for confirmation: "Ready to begin the full LSC KAM setup? (yes/no)"
-
Download the shared source folder FRESH (MANDATORY — hard gate, before any stage). Stages 2 (metadata + config records) and 5 (Data CSVs) read from; those stages do NOT download or delete it — the orchestrator owns one fresh download here and one delete in Phase 9. Always re-pull — never reuse an existing folder (a stale copy would skip newly added components). Delete any pre-existing
.lsc-starter-config/LSStarterConfig/first, then sparse-checkout the subtree fresh:.lsc-starter-configbashrm -rf .lsc-starter-config lsstarter-tmp git clone --no-checkout --depth 1 --filter=blob:none \ https://github.com/SalesforceLabs/LSStarterConfig.git lsstarter-tmp cd lsstarter-tmp && git sparse-checkout init --cone \ && git sparse-checkout set Codey/LSStarterConfig && git checkout && cd .. mv lsstarter-tmp/Codey ./.lsc-starter-config && rm -rf lsstarter-tmphas its own.lsc-starter-config/LSStarterConfig/(pinssfdx-project.json) — deploy steps must run from inside it.sourceApiVersion: 65.0 -
Download gate — verify before proceeding. Confirmand
.lsc-starter-config/LSStarterConfig/sfdx-project.jsonexist (e.g..lsc-starter-config/LSStarterConfig/Data/).ls .lsc-starter-config/LSStarterConfig/sfdx-project.json .lsc-starter-config/LSStarterConfig/Data- If present → set and proceed to Phase 2.
sourceFolderDownloaded: true - If missing/failed → STOP. Do NOT proceed to any stage — every stage depends on this folder. Report the failure (likely: no network / GitHub unreachable, git < 2.25, or disk/permission), leave , and do not advance. Fix the cause and re-run, or download the folder manually into the CWD.
sourceFolderDownloaded: false
- If present → set
-
向用户展示工作流:显示标题"Life Sciences Cloud — 完整KAM设置工作流",展示目标组织,以及6个阶段的顺序和每个阶段的一行摘要:(1) 验证先决条件;(2) 部署初始配置(对象、配置文件、包含KAM与冲刺设置的配置记录、布局、Flexipage);(3) 配置区域;(4) 创建参与者角色与冲刺;(5) 创建KAM数据与计划模板(客户、医疗服务提供者、产品、区域数据 + 目标、任务、指标、已发布的行动计划模板);(6) 配置KAM用户(配置文件/权限集/区域 + 移动元数据缓存)。
-
请求确认:"是否准备开始完整的LSC KAM设置?(是/否)"
-
重新下载共享源文件夹(强制要求——硬校验,在任何阶段前执行)。阶段2(元数据 + 配置记录)和阶段5(数据CSV)会读取;这些阶段不会下载或删除该文件夹——编排器仅在此处下载一次,并在第9环节删除一次。始终重新拉取——切勿复用现有文件夹(过期副本会跳过新增组件)。先删除任何已存在的
.lsc-starter-config/LSStarterConfig/,然后通过稀疏检出重新拉取子树:.lsc-starter-configbashrm -rf .lsc-starter-config lsstarter-tmp git clone --no-checkout --depth 1 --filter=blob:none \ https://github.com/SalesforceLabs/LSStarterConfig.git lsstarter-tmp cd lsstarter-tmp && git sparse-checkout init --cone \ && git sparse-checkout set Codey/LSStarterConfig && git checkout && cd .. mv lsstarter-tmp/Codey ./.lsc-starter-config && rm -rf lsstarter-tmp包含自己的.lsc-starter-config/LSStarterConfig/(固定sfdx-project.json)——部署步骤必须在该目录内运行。sourceApiVersion: 65.0 -
下载校验——继续前验证。确认和
.lsc-starter-config/LSStarterConfig/sfdx-project.json存在(例如执行.lsc-starter-config/LSStarterConfig/Data/)。ls .lsc-starter-config/LSStarterConfig/sfdx-project.json .lsc-starter-config/LSStarterConfig/Data- 若存在 → 设置并推进至第2环节。
sourceFolderDownloaded: true - 若缺失/下载失败 → 终止流程,不得进入任何阶段——所有阶段都依赖该文件夹。报告失败原因(可能是:无网络/GitHub无法访问、git版本低于2.25、磁盘/权限问题),设置,不再推进。修复问题后重新运行,或手动将文件夹下载至当前工作目录。
sourceFolderDownloaded: false
- 若存在 → 设置
Phase 2 — Execute Stage 1: Prerequisites Validation
第2环节——执行阶段1:先决条件验证
-
Run the prerequisites validation following theskill workflow exactly.
life-sciences-prerequisites-validate -
Gate check: If ALL prerequisites pass → proceed to Stage 2. If ANY fails → stop, present the failure table, and ask: "Continue anyway (skip failed prerequisites), or stop and fix them first?" Stop → end the workflow. Continue → proceed with a warning that later stages may fail.
-
严格按照Skill的工作流运行先决条件验证。
life-sciences-prerequisites-validate -
校验检查:若所有先决条件通过 → 推进至阶段2。若有任何一项失败 → 终止流程,展示失败列表,并询问:"是否继续(跳过失败的先决条件),还是先终止并修复问题?"选择终止 → 结束工作流。选择继续 → 推进流程并警告后续阶段可能失败。
Phase 3 — Execute Stage 2: Starter Config Deploy
第3环节——执行阶段2:初始配置部署
-
Run the starter config deployment followingexactly (all 13 deploy steps + the KAM/Sprint config-record edits); read its own reference files as directed. The KAM adaptation deploys only the KAM-relevant layouts (4) and flexipages (6) — all of them, automatically, with no selection prompt — and confirms the StandardValueSet picklist values with the admin (three business-framed groups) BEFORE deploying them, then writes those confirmed values into the
references/stage-2-starter-config-overview.mdandKAMSettings_OrgLevelconfig records.SprintSettings_OrgLevel -
Gate check: Verify the LSC Custom Profile exists:bash
sf data query --query "SELECT Id, Name FROM Profile WHERE Name = 'LSC Custom Profile'" --target-org <org> --json- If profile exists → proceed to Stage 3. If not found → stop and report deployment failure.
-
严格按照运行初始配置部署(所有13个部署步骤 + KAM/冲刺配置记录编辑);按指引读取其参考文件。KAM适配仅部署与KAM相关的布局(4个)和Flexipage(6个)——全部自动部署,无选择提示——并在部署前与管理员确认StandardValueSet选择列表的值(三个业务分组),然后将确认后的值写入
references/stage-2-starter-config-overview.md和KAMSettings_OrgLevel配置记录。SprintSettings_OrgLevel -
校验检查:验证LSC自定义配置文件存在:bash
sf data query --query "SELECT Id, Name FROM Profile WHERE Name = 'LSC Custom Profile'" --target-org <org> --json- 若配置文件存在 → 推进至阶段3。若未找到 → 终止流程并报告部署失败。
Phase 4 — Execute Stage 3: Territory Configuration
第4环节——执行阶段3:区域配置
-
Run the territory configuration following theskill workflow exactly. If an active territory model already exists, use it and show the hierarchy rather than creating a new one.
life-sciences-territory-configure -
Gate check: Verify the territory model is Active and a level-3 territory exists:bash
sf data query --query "SELECT Id, Name, DeveloperName, Territory2Model.State FROM Territory2 WHERE ParentTerritory2.ParentTerritory2Id != null AND Territory2Model.State = 'Active'" --target-org <org> --json- If found → capture the level-3 territory ID + name () and tell the user this leaf territory is the single territory reused for Stage 5 (ProductTerritoryAvailability) and Stage 6 (UserTerritory2Association for both admin and KAM user). Proceed to Stage 4.
OrchestrationState.territoryId - If not found → stop and report the issue.
- If found → capture the level-3 territory ID + name (
-
严格按照Skill的工作流运行区域配置。若已存在激活的区域模型,直接使用该模型并展示层级结构,无需创建新模型。
life-sciences-territory-configure -
校验检查:验证区域模型已激活且存在三级区域:bash
sf data query --query "SELECT Id, Name, DeveloperName, Territory2Model.State FROM Territory2 WHERE ParentTerritory2.ParentTerritory2Id != null AND Territory2Model.State = 'Active'" --target-org <org> --json- 若找到 → 捕获三级区域ID + 名称()并告知用户该叶子区域将在阶段5(ProductTerritoryAvailability)和阶段6(UserTerritory2Association,针对管理员和KAM用户)中复用。推进至阶段4。
OrchestrationState.territoryId - 若未找到 → 终止流程并报告问题。
- 若找到 → 捕获三级区域ID + 名称(
Phase 5 — Execute Stage 4: Participant Role & Sprint
第5环节——执行阶段4:参与者角色与冲刺创建
-
Create the participant role and sprint followingexactly. Only the
references/stage-4-participant-role-and-sprint.md/MasterLabelfields are confirmed with the admin; all other fields are auto-derived and shown for confirmation.Name -
Gate check: Verify a(
ParticipantRole,DeveloperName = 'Rep_Execution_Specialist') and aIsActive = true(StatusSprint) exist. If either is missing → stop and report.Not Started
-
严格按照创建参与者角色与冲刺。仅与管理员确认
references/stage-4-participant-role-and-sprint.md/MasterLabel字段;所有其他字段自动推导并展示供确认。Name -
校验检查:验证存在(
ParticipantRole,DeveloperName = 'Rep_Execution_Specialist')和IsActive = true(状态为Sprint)。若其中任何一项缺失 → 终止流程并报告。Not Started
Phase 6 — Execute Stage 5: KAM Data & Plan Templates
第6环节——执行阶段5:KAM数据与计划模板创建
Both parts run as the admin, in order, from the single reference (Part A = data, Part B = plan templates).
references/stage-5-data-and-plan-templates-overview.md-
Create the KAM data (Part A) following the reference exactly. Pass the Stage-3 level-3 territory. Creates (from the Data CSVs): Account, HealthcareProvider, ObjectTerritory2Association, ProviderAcctTerritoryInfo, Product2, LifeSciMarketableProduct, ContactPointAddress, ProductTerritoryAvailability.
-
Part A gate check: Verify the Account,, and
LifeSciMarketableProduct(on the Stage-3 territory) exist; capture theProductTerritoryAvailabilityID (Part B uses it). If any missing → stop.LifeSciMarketableProduct -
Create the goals, tasks, measures, and action plan template (Part B) following the same reference exactly (stay on the admin login). Creates 2records, a
GoalDefinition, anGoalDefinitionProduct(+ autoActionPlanTemplate), 3ActionPlanTemplateVersionrecords, publishes the template (status → Final), creates anActionPlanTemplateItem, and shares the 2ActionPlanTemplateAssignmentrecords, theGoalDefinition, and bothActionPlanTemplaterecords to the Stage-3 leaf-territory Group (5 manual shares total) so the KAM user reaches them through the territory. Only the record names are confirmed with the admin.ProviderAcctTerritoryInfo -
Part B gate check: Verify the template is published (a
Finalexists), anActionPlanTemplateVersionexists, and the leaf-territory shares exist (2ActionPlanTemplateAssignment+ 1GoalDefinitionShare+ 2ActionPlanTemplateSharewhoseProviderAcctTerritoryInfoShareis the Stage-3 territory Group). If not → stop.UserOrGroupId
两部分均以管理员身份运行,按顺序执行,参考同一文件(A部分=数据,B部分=计划模板)。
references/stage-5-data-and-plan-templates-overview.md-
创建KAM数据(A部分):严格按照参考文件执行。传入阶段3的三级区域。从数据CSV创建:Account、HealthcareProvider、ObjectTerritory2Association、ProviderAcctTerritoryInfo、Product2、LifeSciMarketableProduct、ContactPointAddress、ProductTerritoryAvailability。
-
A部分校验检查:验证Account、和
LifeSciMarketableProduct(关联阶段3的区域)已存在;捕获ProductTerritoryAvailabilityID(B部分会用到)。若任何一项缺失 → 终止流程。LifeSciMarketableProduct -
创建目标、任务、指标和行动计划模板(B部分):严格按照同一参考文件执行(保持管理员登录状态)。创建2条记录、1条
GoalDefinition、1条GoalDefinitionProduct(+自动生成的ActionPlanTemplate)、3条ActionPlanTemplateVersion记录,发布模板(状态→Final),创建1条ActionPlanTemplateItem,并将2条ActionPlanTemplateAssignment记录、GoalDefinition和2条ActionPlanTemplate记录共享至阶段3的叶子区域组(共5次手动共享),以便KAM用户通过区域访问这些记录。仅与管理员确认记录名称。ProviderAcctTerritoryInfo -
B部分校验检查:验证模板已发布(存在状态的
Final)、ActionPlanTemplateVersion已存在、叶子区域共享已生效(2条ActionPlanTemplateAssignment+ 1条GoalDefinitionShare+ 2条ActionPlanTemplateShare,其ProviderAcctTerritoryInfoShare为阶段3的区域组ID)。若未满足 → 终止流程。UserOrGroupId
Phase 7 — Execute Stage 6: KAM User Provisioning
第7环节——执行阶段6:KAM用户配置
-
Provision the KAM user followingexactly. Pass the Stage-3 level-3 territory. Creates a user whose username contains
references/stage-6-user-provisioning-overview.md, assigns the permission sets Health Cloud Starter, Life Sciences Key Account Management, Life Sciences Field Sales Representative, and Life Sciences Core, assigns both the admin and the KAM user to the level-3 territory (confirm with admin — MUST be the same territory used for ProductTerritoryAvailability in Stage 5), and generates the mobile metadata cache via the Connect API.kam -
Gate check (STOP-GATE — Stage 6 completeness). Do NOT accept "user created" as passing. Verify the user ison
IsActive=true, has aLSC Custom Profileto the Stage-3 territory, the metadata cache reachedUserTerritory2Association, and the assigned-permset count is 4 ({HealthCloudStarter, LifeSciencesKeyAccountManager, LifeSciencesFieldSalesRepresentative, LifeSciencesCore}):Status='Active'bashsf data query --query "SELECT COUNT(Id) c FROM PermissionSetAssignment WHERE AssigneeId = '<newUserId>' AND PermissionSet.IsOwnedByProfile = false" --target-org <org> --jsonIf < 2, or the territory assignment or metadata cache is missing, re-run the missing part before finishing.
-
严格按照配置KAM用户。传入阶段3的三级区域。创建用户名包含
references/stage-6-user-provisioning-overview.md的用户,分配权限集Health Cloud Starter、Life Sciences Key Account Management、Life Sciences Field Sales Representative和Life Sciences Core,将管理员和KAM用户均分配至三级区域(需与管理员确认——必须与阶段5中ProductTerritoryAvailability使用的区域相同),并通过Connect API生成移动元数据缓存。kam -
校验检查(终止校验——阶段6完整性)。仅确认"用户已创建"不视为通过。验证用户且使用
IsActive=true、已关联阶段3的区域的LSC Custom Profile、元数据缓存状态为UserTerritory2Association、已分配的权限集数量为4({HealthCloudStarter, LifeSciencesKeyAccountManager, LifeSciencesFieldSalesRepresentative, LifeSciencesCore}):Status='Active'bashsf data query --query "SELECT COUNT(Id) c FROM PermissionSetAssignment WHERE AssigneeId = '<newUserId>' AND PermissionSet.IsOwnedByProfile = false" --target-org <org> --json若数量小于2,或区域分配/元数据缓存缺失,重新运行缺失部分后再结束流程。
Phase 8 — Final Summary, Cleanup & On-Device Validation
第8环节——最终总结、清理与设备端验证
-
Display the complete workflow summary — a "Life Sciences Cloud KAM Setup Complete" header, then one block per stage with actual values: (1) prerequisites confirmed; (2) objects/profiles/config records deployed, KAM & Sprint settings written, layouts + flexipages, 28 trigger handlers; (3) Territory Model(Active) + Level-3
<model>; (4) Participant Role<territory>+ SprintRep Execution Specialist; (5) Account + HCP, product master data, ProductTerritoryAvailability on<name>, 2 Goal Definitions, ActionPlanTemplate<territory>(Final) + 3 items + assignment, goals + template + 2 PATI shared to territory<name>; (6) User<territory>(<name>) on<username>, permsets Health Cloud Starter + Life Sciences Key Account Management + Life Sciences Field Sales Representative + Life Sciences Core, TerritoryLSC Custom Profile(admin + KAM), mobile metadata cache generated. Close: "The org is ready for Life Sciences Cloud key account management workflows."<territory> -
Cleanup — delete the shared source folder ONCE. After the final summary (all 6 stages complete), run from the CWD:bash
rm -rf .lsc-starter-configDo this silently — do NOT print a cleanup line or mention the deletion. Skip if the workflow stopped on a failure and the user may resume — keep the folder so a resumed stage can still read it. This is the single deletion for the whole flow; child skills never delete it. -
Display the on-device (iPad) validation script and await confirmation. Once the metadata cache isand the summary is shown, display the script verbatim from
Status='Active'(the login uses the Stage-6 KAM user's credentials), then wait for the user to confirm the on-device steps succeeded. Once confirmed, the setup is complete.references/stage-6-ipad-validation-script.md
-
展示完整工作流总结:显示标题"Life Sciences Cloud KAM设置完成",然后按阶段展示实际值:(1) 先决条件已确认;(2) 对象/配置文件/配置记录已部署,KAM与冲刺设置已写入,布局 + Flexipage,28个触发器处理程序;(3) 区域模型(已激活) + 三级区域
<model>;(4) 参与者角色<territory>+ 冲刺Rep Execution Specialist;(5) 客户 + HCP,产品主数据,关联<name>的ProductTerritoryAvailability,2条目标定义,行动计划模板<territory>(最终版) + 3个任务 + 分配,目标 + 模板 + 2个PATI已共享至区域<name>;(6) 用户<territory>(<name>)使用<username>,权限集Health Cloud Starter + Life Sciences Key Account Management + Life Sciences Field Sales Representative + Life Sciences Core,区域LSC Custom Profile(管理员 + KAM),移动元数据缓存已生成。结束语:"该组织已就绪,可运行Life Sciences Cloud关键客户管理工作流。"<territory> -
清理——删除共享源文件夹一次。在展示最终总结后(所有6个阶段完成),从当前工作目录执行:bash
rm -rf .lsc-starter-config此操作静默执行——无需打印清理日志或提及删除操作。若工作流因失败终止且用户可能恢复流程,跳过此步骤——保留文件夹以便恢复阶段可读取。这是整个流程中唯一的删除操作;子Skill绝不会删除该文件夹。 -
展示设备端(iPad)验证脚本并等待确认。一旦元数据缓存状态为且已展示总结,原样展示
Status='Active'中的脚本(登录使用阶段6创建的KAM用户凭据),然后等待用户确认设备端步骤已成功完成。确认后,设置流程完成。references/stage-6-ipad-validation-script.md
State Tracking
状态跟踪
Maintain overall orchestration state:
text
OrchestrationState = {
targetOrg: string,
sourceFolderDownloaded: boolean, // downloaded in Phase 1, deleted in Phase 9
territoryId?: string, territoryName?: string, // captured in Stage 3, reused in Stages 5 & 6
stages: [
{ name: "Prerequisites", status: "pending|running|passed|failed|skipped" },
{ name: "StarterConfig", status: "pending|running|passed|failed" },
{ name: "TerritorySetup", status: "pending|running|passed|failed", territoryId?: string, territoryName?: string },
{ name: "ParticipantSprint", status: "pending|running|passed|failed", roleId?: string, sprintId?: string },
{ name: "DataAndPlanTemplates",status: "pending|running|passed|failed", accountId?: string, marketableProductId?: string, templateVersionId?: string },
{ name: "UserProvisioning", status: "pending|running|passed|failed", userId?: string, username?: string }
]
}维护整体编排状态:
text
OrchestrationState = {
targetOrg: string,
sourceFolderDownloaded: boolean, // 第1环节下载,第9环节删除
territoryId?: string, territoryName?: string, // 阶段3捕获,阶段5 & 6复用
stages: [
{ name: "Prerequisites", status: "pending|running|passed|failed|skipped" },
{ name: "StarterConfig", status: "pending|running|passed|failed" },
{ name: "TerritorySetup", status: "pending|running|passed|failed", territoryId?: string, territoryName?: string },
{ name: "ParticipantSprint", status: "pending|running|passed|failed", roleId?: string, sprintId?: string },
{ name: "DataAndPlanTemplates",status: "pending|running|passed|failed", accountId?: string, marketableProductId?: string, templateVersionId?: string },
{ name: "UserProvisioning", status: "pending|running|passed|failed", userId?: string, username?: string }
]
}Idempotent Stage Transitions & Mid-Flow Changes
幂等阶段转换与流程中变更
Stages are not re-entrant. Before executing any stage, check its : → reply "Stage N is already in progress" and take no action; → ask explicit confirmation before re-running; → re-run (recovery); → advance. Set at execution start (not on user input) so accidental double-confirms never run a stage twice.
statusrunningpassedfailedpendingrunningIf the user requests a change to an earlier stage's inputs while a later stage is in progress/pending, run an impact assessment first: acknowledge without applying, identify affected vs. unaffected stages, present options (re-run affected / apply forward only / cancel), and wait for the decision. Surface destructive-change warnings (an activated territory model can't be deleted; an existing user/records/published template remain).
The full behavior matrix, impact-assessment template, per-change impact mapping, and destructive-change warnings are in .
references/state-machine-and-changes.md阶段不可重入。在执行任何阶段前,检查其: → 回复"阶段N正在执行中"且不执行任何操作; → 重新运行前需明确确认; → 重新运行(恢复); → 推进流程。在执行开始时设置状态(而非用户输入时),避免意外重复确认导致阶段重复运行。
statusrunningpassedfailedpendingrunning若用户在后续阶段执行中/待执行时请求修改早期阶段的输入,先运行影响评估:确认收到请求但暂不应用,识别受影响和不受影响的阶段,展示选项(重新运行受影响阶段 / 仅向前应用变更 / 取消),等待用户决策。需提示破坏性变更警告(已激活的区域模型无法删除;现有用户/记录/已发布模板会保留)。
完整行为矩阵、影响评估模板、各变更的影响映射和破坏性变更警告详见。
references/state-machine-and-changes.mdRules / Constraints
规则/约束
- Org: run Phase 0 org selection first; never silently reuse the default org.
- Shared folder: download exactly once (Phase 1 hard gate), delete it exactly once (Phase 9); child skills never touch it — Stages 2 and 5 read it, so proceeding without it fails downstream.
.lsc-starter-config/LSStarterConfig - Order: execute stages strictly 1→6, gating each on prior success; capture each stage's outputs (IDs, names) for later stages.
- Territory invariant: reuse the SAME Stage-3 level-3 territory () for Stage 5 (ProductTerritoryAvailability) and Stage 6 (user alignment), or the KAM user sees no data.
OrchestrationState.territoryId - Confirmation: confirm only the fields each stage marks admin-confirmable; auto-derive the rest and show for confirmation.
- Idempotency: never re-execute a /
runningstage without confirmation (setpassedat execution start); impact-assess before applying mid-flow changes.running
- 组织:优先执行第0环节的组织选择;切勿默认复用现有组织。
- 共享文件夹:仅在第1环节下载一次(硬校验),仅在第9环节删除一次;子Skill绝不会操作该文件夹——阶段2和5会读取它,因此无该文件夹时后续流程会失败。
.lsc-starter-config/LSStarterConfig - 顺序:严格按1→6的顺序执行阶段,每个阶段依赖前一阶段的成功;捕获每个阶段的输出(ID、名称)供后续阶段使用。
- 区域一致性:阶段3的三级区域()需在阶段5(ProductTerritoryAvailability)和阶段6(用户关联)中复用,否则KAM用户无法查看数据。
OrchestrationState.territoryId - 确认:仅确认每个阶段标记为需管理员确认的字段;其余字段自动推导并展示供确认。
- 幂等性:未经确认,不得重新执行/
running状态的阶段(执行开始时设置passed);流程中应用变更前需进行影响评估。running
Gotchas
常见问题
| Issue | Resolution |
|---|---|
| Source download fails in Phase 1 | Hard stop — do NOT run any stage. Fix the cause or download |
| No connected orgs found | Go straight to the fresh-org login ( |
| Artifacts exist from a prior run | Child skills/references are idempotent/upsert-safe — query to confirm, then skip or re-run |
| Stage re-triggered, or earlier input changed mid-flow | See |
| 问题 | 解决方案 |
|---|---|
| 第1环节源文件夹下载失败 | 终止流程——不得运行任何阶段。修复问题或手动将 |
| 未找到已连接组织 | 直接进入第0环节的新组织登录流程( |
| 存在之前运行的遗留产物 | 子Skill/参考文件支持幂等/更新插入——查询确认后,跳过或重新运行 |
| 阶段被重新触发,或流程中早期输入被修改 | 详见 |
Resume / Partial Re-run
恢复/部分重新运行
If the user may have already completed some stages, ask which, then verify each claimed-complete stage by querying the org (1 = ask; 2 = ; 3 = active model + L3 territory; 4 = + ; 5 = Account + + version + assignment; 6 = user + permsets + territory), skip verified stages, and resume from the first incomplete one. Exact per-stage queries: → Resume Logic.
LSC Custom ProfileParticipantRoleSprintProductTerritoryAvailabilityFinalkamreferences/orchestration-flow.md若用户可能已完成部分阶段,询问已完成的阶段,然后通过查询组织验证每个声称已完成的阶段(1 = 询问;2 = 存在;3 = 激活的模型 + 三级区域存在;4 = + 存在;5 = Account + + 版本 + 分配存在;6 = 用户 + 权限集 + 区域存在),跳过已验证的阶段,从第一个未完成的阶段恢复。各阶段的具体查询语句: → 恢复逻辑。
LSC Custom ProfileParticipantRoleSprintProductTerritoryAvailabilityFinalkamreferences/orchestration-flow.mdReference File Index
参考文件索引
| File | When to read |
|---|---|
| At start — dependency diagram, gate + resume-detection queries, timing |
| On a re-triggered stage or a mid-flow input change |
| Stage 2 — 13-step deploy + KAM/Sprint config records (points to sibling refs) |
| Stage 4 — participant role + sprint |
| Stage 5 — KAM data creation (Part A, points to its data ref) + goals, tasks, measures, action plan template (Part B) |
| Stage 6 — user provisioning + metadata cache (points to sibling refs) |
| Final step — on-device (iPad) validation script shown after the metadata cache is Active |
| 文件 | 读取时机 |
|---|---|
| 流程启动时——依赖关系图、校验 + 恢复检测查询、时间规划 |
| 阶段被重新触发或流程中输入被修改时 |
| 阶段2时——13步部署 + KAM/冲刺配置记录(指向同级参考文件) |
| 阶段4时——参与者角色 + 冲刺创建 |
| 阶段5时——KAM数据创建(A部分,指向其数据参考文件) + 目标、任务、指标、行动计划模板创建(B部分) |
| 阶段6时——用户配置 + 元数据缓存(指向同级参考文件) |
| 最终步骤时——元数据缓存激活后展示设备端(iPad)验证脚本 |