@salesforce/afv-skills 1.31.0 → 1.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/agentforce-bot-upgrade/SKILL.md +217 -0
- package/skills/agentforce-bot-upgrade/references/extraction-blueprint.md +242 -0
- package/skills/agentforce-bot-upgrade/references/generate-agent-spec.md +128 -0
- package/skills/agentforce-bot-upgrade/references/handoff-output-format.md +208 -0
- package/skills/agentforce-bot-upgrade/references/input-contract.md +101 -0
- package/skills/agentforce-bot-upgrade/references/mapping-rules.md +113 -0
- package/skills/agentforce-bot-upgrade/references/planner-workflow-reference.md +78 -0
- package/skills/agentforce-bot-upgrade/references/post-conversion-enhancements-reference.md +67 -0
- package/skills/agentforce-bot-upgrade/references/quality-checklist.md +33 -0
- package/skills/agentforce-bot-upgrade/references/sf-cli-bot-reference.md +116 -0
- package/skills/dx-devops-work-item-manage/SKILL.md +270 -0
- package/skills/dx-devops-work-item-manage/examples/common-workflows.md +479 -0
- package/skills/dx-devops-work-item-manage/references/cli-commands.md +476 -0
- package/skills/dx-org-manage/SKILL.md +8 -5
- package/skills/dx-org-trial-expiration-check/SKILL.md +239 -0
- package/skills/dx-org-trial-expiration-check/scripts/check_expiration.sh +588 -0
- package/skills/experience-ui-bundle-app-coordinate/SKILL.md +12 -9
- package/skills/experience-ui-bundle-custom-app-generate/SKILL.md +29 -5
- package/skills/experience-ui-bundle-custom-app-generate/references/configure-metadata-custom-application.md +1 -1
- package/skills/experience-ui-bundle-custom-app-generate/scripts/resolve-uibundle-path.sh +30 -0
- package/skills/experience-ui-bundle-features-generate/SKILL.md +86 -11
- package/skills/experience-ui-bundle-features-generate/references/conflict-resolution-schema.json +20 -0
- package/skills/experience-ui-bundle-features-generate/scripts/verify-react-bundle.sh +14 -0
- package/skills/experience-ui-bundle-frontend-generate/SKILL.md +6 -1
- package/skills/experience-ui-bundle-frontend-generate/references/component.md +34 -1
- package/skills/experience-ui-bundle-frontend-generate/references/page.md +1 -1
- package/skills/experience-ui-bundle-project-generate/SKILL.md +111 -0
- package/skills/experience-ui-bundle-project-generate/scripts/flatten-project.mjs +33 -0
- package/skills/platform-custom-lightning-type-generate/SKILL.md +9 -14
- package/skills/platform-custom-lightning-type-generate/references/widget-rendition.md +27 -111
- package/skills/platform-lightning-type-widget-coordinate/SKILL.md +214 -0
- package/skills/platform-lightning-type-widget-coordinate/examples/existing-lightning-type-with-widget-prompt.md +80 -0
- package/skills/platform-lightning-type-widget-coordinate/examples/new-lightning-type-with-widget-prompt.md +75 -0
- package/skills/platform-lightning-type-widget-coordinate/references/build-plan-format.md +67 -0
- package/skills/platform-lightning-type-widget-coordinate/references/lightning-type-discovery.md +124 -0
- package/skills/platform-lightning-type-widget-coordinate/references/validation-gates.md +130 -0
- package/skills/platform-sharing-owd-configure/SKILL.md +142 -0
- package/skills/platform-sharing-owd-configure/examples/get_owd_output.md +38 -0
- package/skills/platform-sharing-owd-configure/examples/update_owd_output.md +44 -0
- package/skills/platform-sharing-owd-configure/references/access_levels.md +49 -0
- package/skills/platform-sharing-owd-configure/references/metadata_api_approach.md +69 -0
- package/skills/platform-sharing-rules-generate/SKILL.md +89 -19
- package/skills/platform-sharing-rules-generate/examples/test-cases.md +381 -0
- package/skills/platform-widget-generate/SKILL.md +241 -0
- package/skills/platform-widget-generate/examples/conditional.json +73 -0
- package/skills/platform-widget-generate/examples/list-with-foreach.json +66 -0
- package/skills/platform-widget-generate/examples/single-object.json +64 -0
- package/skills/platform-widget-generate/references/schema-from-lightning-type.md +76 -0
- package/skills/platform-widget-generate/references/widget-bundle-layout.md +116 -0
- package/skills/platform-widget-generate/references/widget-meta-directives.md +130 -0
- package/skills/sales-agentforce-pipeline-management-configure/SKILL.md +268 -0
- package/skills/sales-agentforce-pipeline-management-configure/assets/field-completion-template.genAiPromptTemplate-meta.xml +141 -0
- package/skills/sales-agentforce-pipeline-management-configure/assets/pipeline_management_flow.flow-meta.xml +548 -0
- package/skills/sales-agentforce-pipeline-management-configure/assets/sales_management_agent.agent +2938 -0
- package/skills/sales-agentforce-pipeline-management-configure/assets/sales_management_agent.bundle-meta.xml +4 -0
- package/skills/sales-agentforce-pipeline-management-configure/assets/sfdx-project.json +12 -0
- package/skills/sales-agentforce-pipeline-management-configure/assets/stage-descriptions/bant.txt +11 -0
- package/skills/sales-agentforce-pipeline-management-configure/assets/stage-descriptions/meddic.txt +11 -0
- package/skills/sales-agentforce-pipeline-management-configure/assets/stage-descriptions/spiced.txt +11 -0
- package/skills/sales-agentforce-pipeline-management-configure/examples/custom-prompt-instructions.md +317 -0
- package/skills/sales-agentforce-pipeline-management-configure/references/admin-communication.md +355 -0
- package/skills/sales-agentforce-pipeline-management-configure/references/agent-creation.md +383 -0
- package/skills/sales-agentforce-pipeline-management-configure/references/auth-and-cli.md +146 -0
- package/skills/sales-agentforce-pipeline-management-configure/references/automation-matrix.md +23 -0
- package/skills/sales-agentforce-pipeline-management-configure/references/autonomous-updates.md +215 -0
- package/skills/sales-agentforce-pipeline-management-configure/references/canonical-agent-path.md +75 -0
- package/skills/sales-agentforce-pipeline-management-configure/references/data-sources.md +155 -0
- package/skills/sales-agentforce-pipeline-management-configure/references/field-completion-prompt-template.md +120 -0
- package/skills/sales-agentforce-pipeline-management-configure/references/field-completion-prompts.md +149 -0
- package/skills/sales-agentforce-pipeline-management-configure/references/flags.md +13 -0
- package/skills/sales-agentforce-pipeline-management-configure/references/flow-clone-from-template.md +447 -0
- package/skills/sales-agentforce-pipeline-management-configure/references/metadata-inventory.md +330 -0
- package/skills/sales-agentforce-pipeline-management-configure/references/opportunity-stages.md +246 -0
- package/skills/sales-agentforce-pipeline-management-configure/references/repair-diagnostics.md +265 -0
- package/skills/sales-agentforce-pipeline-management-configure/references/setup-order.md +263 -0
- package/skills/sales-agentforce-pipeline-management-configure/references/soap-api-enablement.md +528 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/CHANGES.md +180 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/README.md +56 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/add-field-suggestion.sh +679 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/create-agent.sh +302 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/create-flow.sh +250 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/define-agent-access.sh +430 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/deploy-settings.sh +77 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/enable-deal-agent.sh +241 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/enable-prerequisites.sh +538 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/flow-debug-and-verify.sh +385 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/retrieve-settings.sh +131 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/setup-all.sh +2791 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/agent-bundle-publish.sh +189 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/agent-detection.sh +239 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/flow-builder.sh +238 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/psg.sh +48 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/soap.sh +140 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/stage-descriptions.sh +448 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/test-opp.sh +166 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/verify-all.sh +636 -0
- package/skills/sales-agentforce-pipeline-management-configure/scripts/verify-prompt-generation.sh +346 -0
package/skills/sales-agentforce-pipeline-management-configure/references/field-completion-prompts.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Field Completion Prompt Templates
|
|
2
|
+
|
|
3
|
+
This reference covers adding Pipeline Management field-update suggestions for Opportunity text fields beyond the two the pipeline ships with (`NextStep` and `StageName`).
|
|
4
|
+
|
|
5
|
+
Everything here was verified end-to-end on a live org (deploy → activate → generate). The canonical XML lives at `assets/field-completion-template.genAiPromptTemplate-meta.xml`; the automation that fills it in and wires the flow is `scripts/add-field-suggestion.sh`.
|
|
6
|
+
|
|
7
|
+
> **Naming note — "Field Generation" vs "Field Completion".** The prompt-template metadata `<type>` is `einstein_gpt__fieldCompletion` (used everywhere in metadata, filenames, and this repo — do not change it). In the **Setup UI** (Prompt Builder), Salesforce labels this template category **"Field Generation"**. They are the same thing: an admin looking in Setup should look for **Field Generation**, not "Field Completion".
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Use the script — do not hand-author
|
|
12
|
+
|
|
13
|
+
**`scripts/add-field-suggestion.sh` is the supported path.** It performs the full, order-sensitive sequence deterministically so you never have to guess version identifiers or edit the flow by hand:
|
|
14
|
+
|
|
15
|
+
> **Field cap:** Pipeline Management manages at most **5 Opportunity fields total**, and the two OOTB fields (`NextStep`, `StageName`) count toward that 5. `add-field-suggestion.sh` enforces this — when the flow already wires 5 fields, adding a new one fails with a "field cap reached" error (adding a field already wired is an idempotent no-op and is never blocked). To add a 6th, remove one first (decline an OOTB field during `setup-all.sh`, or strip it from the flow).
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
cd scripts
|
|
20
|
+
./add-field-suggestion.sh <org-alias> <FieldApiName> \
|
|
21
|
+
[--label "Human Label"] \
|
|
22
|
+
[--instruction "one line of field-specific extraction guidance"] \
|
|
23
|
+
[--goal "one sentence: what the model should think about"] \
|
|
24
|
+
[--name RecommendXforOpp] \
|
|
25
|
+
[--opp <OpportunityId>] \
|
|
26
|
+
[--verify-with-note] \
|
|
27
|
+
[--skip-flow]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Example (the exact call verified on the org):
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
./add-field-suggestion.sh pipeline-mgmt-org Deal_Momentum__c \
|
|
34
|
+
--label "Deal Momentum" \
|
|
35
|
+
--goal "how much forward momentum this deal has and what is stalling it" \
|
|
36
|
+
--instruction "Summarize momentum signals: engagement cadence, stakeholder involvement, and blockers." \
|
|
37
|
+
--verify-with-note
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
What the script does, in order:
|
|
41
|
+
|
|
42
|
+
1. **Validate the field** — describes the Opportunity and confirms the field is plain Text (`type=string`) or Text Area ≤ 255 (`type=textarea`, not `htmlFormatted`), `updateable`, not calculated, length ≤ 255. If the field exists in the Tooling `FieldDefinition` but not in the describe, it reports "field has no FLS" and prints the exact `FieldPermissions` grant command instead of failing silently.
|
|
43
|
+
2. **Fill the canonical template** — substitutes placeholders into `assets/field-completion-template.genAiPromptTemplate-meta.xml`, preserving the OOTB instruction body verbatim.
|
|
44
|
+
3. **Deploy + activate (the version round-trip)** — deploys `Published` with no version identifiers, retrieves the platform-generated `<versionIdentifier>`, sets it as `<activeVersionIdentifier>`, and redeploys to activate. Confirms active via the `/einstein/prompt-templates` endpoint.
|
|
45
|
+
4. **Wire the flow** — idempotently adds the field API name to the `Process_Field_Update_Suggestions` flow's `AddOppFieldsToCollection` assignment (skipped with `--skip-flow`).
|
|
46
|
+
5. **Verify (optional, `--verify-with-note`)** — seeds a ContentNote on a sample opportunity and calls the synchronous `/generations` endpoint, printing the generated JSON.
|
|
47
|
+
|
|
48
|
+
Only read the rest of this doc if you need to understand *why* the pattern is shaped the way it is, or to debug a failure.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Prerequisites
|
|
53
|
+
|
|
54
|
+
- The field must be a **standard or custom text field** on Opportunity — plain Text (`type=string`) or Text Area ≤ 255 (`type=textarea`, not `htmlFormatted`). Long Text Area (length > 255), Rich Text Area (`htmlFormatted`), picklist, formula, and non-text fields are not supported.
|
|
55
|
+
- `SuggestedNewValue` is capped at the **field's own length** (≤ 255). The script sets the cap from the field's `length` automatically.
|
|
56
|
+
- The field must be **FLS-accessible** to the running user. A freshly deployed custom field has no field-level security and is invisible to `sf sobject describe` until you grant it — this is the single most common first-run failure.
|
|
57
|
+
- A field can have only **one** field-completion prompt template.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Verified template structure (v67)
|
|
62
|
+
|
|
63
|
+
The canonical asset is the source of truth. The invariants below are what make it work; do not "simplify" them.
|
|
64
|
+
|
|
65
|
+
| Element | Correct value | Common wrong value to avoid |
|
|
66
|
+
|---------|---------------|-----------------------------|
|
|
67
|
+
| `<type>` | `einstein_gpt__fieldCompletion` | `field_generation` |
|
|
68
|
+
| Input `<apiName>` | `RelatedEntity` (platform-fixed for MDAPI-authored templates) | `Opportunity` |
|
|
69
|
+
| Input `<referenceName>` | `Input:Opportunity` | — |
|
|
70
|
+
| Body merge fields | `{!$Input:Opportunity.<field>}` | `{!$Input:Opportunity}` |
|
|
71
|
+
| `<relatedField>` | object-qualified: `Opportunity.<field>` | bare `<field>` |
|
|
72
|
+
| Grounding | a `<templateDataProviders>` block (`flow://sales_pipe_mgmt__GetOppGroundingData`) is **required** | omitting it |
|
|
73
|
+
| `<status>` | `Published` | `Draft` |
|
|
74
|
+
| Version | none at author time — added by the deploy round-trip | hand-authored `versionNumber` / `activeVersion` |
|
|
75
|
+
|
|
76
|
+
There is **no** `templateType`, `versionNumber`, or `activeVersion` element. The correct activation field is `<activeVersionIdentifier>`, and its value is the platform-generated `<versionIdentifier>` returned by a retrieve — never hand-authored or guessed.
|
|
77
|
+
|
|
78
|
+
**`GenAiPromptTemplate` IS CLI-retrievable** for user-created templates (this is how the script gets the version identifier). Only the managed `sales_pipe_mgmt__*` templates are non-retrievable. Any doc or comment claiming user templates cannot be retrieved is wrong and was the root cause of prior version-identifier guessing.
|
|
79
|
+
|
|
80
|
+
The instruction body is the OOTB Pipeline Management body verbatim; only the field name and two field-specific lines (goal + instruction) change. Character caps inside the body: `SuggestedNewValue` = the field length, `Reasoning` = 250, `Snippet` = 100, `DueDate` = `"30 days"`.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## The three requirements for a field to produce suggestions
|
|
85
|
+
|
|
86
|
+
A field generates `AiGenActionItem` records only when **all three** hold:
|
|
87
|
+
|
|
88
|
+
1. **Template deployed and activated** — `<status>Published</status>` with a valid `<activeVersionIdentifier>` (the script's round-trip).
|
|
89
|
+
2. **Field added to the flow** — the field API name is a `<stringValue>` in the `AddOppFieldsToCollection` assignment (collection `OpportunityFields`), which feeds the `getOrExecFieldUpdtSuggestion` action's `fieldApiNames` parameter.
|
|
90
|
+
3. **Field FLS-accessible** — the running/agent user can read and edit the field.
|
|
91
|
+
|
|
92
|
+
Missing any one produces zero suggestions with no error.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Data source grounding flow
|
|
97
|
+
|
|
98
|
+
Every field-completion template references `{!$Flow:sales_pipe_mgmt__GetOppGroundingData.Prompt}` — a PromptFlow (not a schedule-triggered flow) provisioned by Pipeline Management. It gathers `ContentNote`, `EmailMessage` (if Einstein Activity Capture is on), and call transcripts (if Einstein Conversation Insights is on) from the last 30 days and formats them into the prompt input.
|
|
99
|
+
|
|
100
|
+
Do **not** change this reference, invoke the flow directly, or build your own replacement. See `references/data-sources.md` for enabling the underlying data products.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Verifying generation
|
|
105
|
+
|
|
106
|
+
Two ways to confirm a template works:
|
|
107
|
+
|
|
108
|
+
**Synchronous (deterministic, preferred for testing)** — the `/generations` endpoint returns the model output directly, proving prompt + grounding + field binding are all correct:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
sf api request rest "/services/data/v64.0/einstein/prompt-templates/<TemplateName>/generations" \
|
|
112
|
+
--method POST --target-org "$ORG" \
|
|
113
|
+
--body '{"isPreview":false,"inputParams":{"valueMap":{"Input:Opportunity":{"value":{"id":"<oppId>"}}}},"additionalConfig":{"numGenerations":1,"temperature":0,"applicationName":"PromptTemplateGenerationsInvocable"}}'
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
`.generations[0].text` is the JSON output; `.prompt` is the fully resolved prompt. Note `isPreview` **must** be `false` — preview mode cannot resolve the `GetOppGroundingData` data provider (a preview-mode limitation, not a config error). This is exactly what `--verify-with-note` runs.
|
|
117
|
+
|
|
118
|
+
**Asynchronous (the real pipeline)** — suggestions land as `AiGenActionItem` records ~3 minutes after the schedule-triggered flow runs. Query them by Opportunity and field:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
sf data query -q "SELECT Id, Subject, Status, SuggestedNewValue FROM AiGenActionItem WHERE Type = 'FIELD_UPDATE' AND ParentId = '<oppId>' ORDER BY CreatedDate DESC" --target-org "$ORG" --json 2>/dev/null
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`ParentId` = the Opportunity Id (filterable), `Subject` = the field API name (e.g. `Risk__c`). Poll ≥ 240s before concluding failure — a short poll is the #1 false negative. There is **no** `FieldCompletion` object.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Troubleshooting
|
|
129
|
+
|
|
130
|
+
### No suggestions generated (async)
|
|
131
|
+
Check the three requirements above in order: is the template active (`/einstein/prompt-templates`)? Is the field in the flow's `AddOppFieldsToCollection` collection? Does the running user have FLS? Then confirm the grounding flows are active (`SELECT ApiName, IsActive FROM FlowDefinitionView WHERE NamespacePrefix='sales_pipe_mgmt'`) and that the test opportunity is eligible (`IsClosed=false`, `CloseDate` within +90 days) with recent notes/emails/calls. Poll ≥ 240s.
|
|
132
|
+
|
|
133
|
+
### `/generations` returns empty SuggestedNewValue
|
|
134
|
+
The template is fine; the opportunity has no grounding data in the last 30 days. Seed a ContentNote (`--verify-with-note` does this) or use an opportunity with recent activity.
|
|
135
|
+
|
|
136
|
+
### Field "not found on Opportunity"
|
|
137
|
+
The field has no FLS and is invisible to describe. The script detects this and prints the `FieldPermissions` grant; run that command, then re-run.
|
|
138
|
+
|
|
139
|
+
### Deploy succeeds but template never activates
|
|
140
|
+
You likely skipped the version round-trip or hand-authored an identifier. Let the script own activation — deploy Published with no identifiers, retrieve the real `<versionIdentifier>`, set `<activeVersionIdentifier>`, redeploy.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Notes
|
|
145
|
+
|
|
146
|
+
- Only **text fields** (`type=string`, length ≤ 255) are supported.
|
|
147
|
+
- Each field gets exactly **one** template; re-running the script for an existing field is idempotent.
|
|
148
|
+
- Suggestions are `AiGenActionItem` records; `DueDate` of `"30 days"` means they expire after 30 days.
|
|
149
|
+
- Always use `2>/dev/null` on `sf … --json` piped to jq, and `sf api request rest` (not raw curl) on this org.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# setup-all.sh Flags Reference
|
|
2
|
+
|
|
3
|
+
- `--check-license` — **preflight only**: run auth + the capability gate, then exit (0 = capable, 1 = unlicensed with a printed blocker). Takes no `--fields`, asks nothing, changes nothing. Run this FIRST, before any clarifying question (Step 0 above).
|
|
4
|
+
- `--through-phase prompts` — run enablement → provisioning → prompt-template deploy/activate, then **stop before the flow is built**. Hands off to the agent tune-loop. (Call 1 above.)
|
|
5
|
+
- `--from-phase flow` — skip the already-done enablement/provisioning/templates and **resume at the flow build** (build + activate flow, agent, PSG recalc, final verify). Pass the same `--fields`. (Call 2 above.) Mutually exclusive with `--through-phase`.
|
|
6
|
+
- `--fields "NextStep,StageName,Risk__c"` — comma-separated Opportunity field API names to manage. **At least 1 is required**; setup aborts if zero are selected (no default to `NextStep`). Max 5 (OOTB fields count). Required in `--non-interactive` mode; interactive mode prompts for it. The flow is built with **only** these fields.
|
|
7
|
+
- `--field-goal "FieldName:<text>"` — custom goal for a specific field (repeatable; format `Field:text`). Only meaningful for non-`StageName` fields.
|
|
8
|
+
- `--field-instruction "FieldName:<text>"` — custom instruction for a specific field (repeatable; same format). For `NextStep`, supplying either flag deploys an OVERRIDE of the OOTB managed prompt; omit both to keep the OOTB prompt.
|
|
9
|
+
- `--skip-prompt-verification` — bypass the Phase 4e prompt-verification step entirely (which seeds a test opportunity + note and shows generated suggestions before activating the flow). In `--non-interactive` runs the step still **runs and prints** the generated suggestions (informational) — only the interactive yes/no *gate* is dropped, so the flow proceeds without blocking. **When you drive setup non-interactively (e.g. as an agent), relay the printed suggestions back to the user** so they get the review the interactive gate would have given.
|
|
10
|
+
- `--autonomous` — enable autonomous field updates (`enableDealAgentAutoApproveAllTasks=true`); the agent auto-applies suggestions with no human review. Omit to keep suggestions-only. In an interactive run the script asks; in `--non-interactive` mode it stays off unless the flag is passed.
|
|
11
|
+
- `--create-stage-descriptions` — create sales-methodology stage descriptions (needed only for `StageName` suggestions, and only prompted/relevant when `StageName` is in `--fields`). Omit to skip. Never auto-created silently in non-interactive mode.
|
|
12
|
+
- `--non-interactive` / `--yes` — run without prompts (also implied when stdin is not a TTY). Requires `--fields`. Combined with the opt-in flags this gives fully unattended setup; without them the run stays on the safe defaults.
|
|
13
|
+
- `--users "a@x.com,b@x.com"` — explicit comma-separated usernames to also grant the `SalesManagementUserPsg`, in addition to the running user. This is the **only** way to add users in a non-interactive run. **NEVER** query all users / all standard users and bulk-assign the PSG — grant only the running user plus the explicit `--users` (or interactively-typed) list. Email format is validated — each value must match a valid email pattern.
|
package/skills/sales-agentforce-pipeline-management-configure/references/flow-clone-from-template.md
ADDED
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
# Flow Clone from Template
|
|
2
|
+
|
|
3
|
+
The schedule-triggered flow for Pipeline Management must be cloned from the template `sales_pipe_mgmt__OppSuggGenSchFlow`. This template is provisioned when Pipeline Management is enabled but never activates itself.
|
|
4
|
+
|
|
5
|
+
## Why Clone Instead of Build
|
|
6
|
+
|
|
7
|
+
The template flow contains:
|
|
8
|
+
- Complete flow body with all elements and connectors
|
|
9
|
+
- Invocable action calls using `getOrExecFieldUpdtSuggestion` action type (NOT `generatePromptResponse`)
|
|
10
|
+
- Namespace-prefixed references to prompt templates (`sales_pipe_mgmt__RecommendStageforOpp`, `sales_pipe_mgmt__RecommendNextStepforOpp`)
|
|
11
|
+
- Bot definition lookups and opportunity team member assignment logic
|
|
12
|
+
- Schedule trigger configuration
|
|
13
|
+
|
|
14
|
+
Building this from scratch would require knowing:
|
|
15
|
+
- Exact action type and input parameters
|
|
16
|
+
- Internal action names
|
|
17
|
+
- Flow element connection paths
|
|
18
|
+
- Variable declarations and assignments
|
|
19
|
+
|
|
20
|
+
The template already has all of this correct — cloning preserves the entire working structure.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Flow Detection: ApiName is primary; SourceTemplateId is best-effort
|
|
25
|
+
|
|
26
|
+
`SourceTemplateId` is a real field on `FlowDefinitionView` (confirmed in API v67.0). The
|
|
27
|
+
Setup-UI "Save As" clone path populates it with the template's fully-qualified name
|
|
28
|
+
(e.g., `sales_pipe_mgmt__OppSuggGenSchFlow`). **However, a Metadata-API deploy of the
|
|
29
|
+
pre-retrieved template (the PRIMARY clone path — Method 1) does NOT populate
|
|
30
|
+
`FlowDefinitionView.SourceTemplateId`**, even though the deployed XML carries the
|
|
31
|
+
`<sourceTemplate>` element and the flow is fully active and wired. Org-verified on a
|
|
32
|
+
fresh SDB3 org: the `SourceTemplateId` query returned zero rows while the flow was
|
|
33
|
+
active. So detect by **ApiName first**, and treat `SourceTemplateId` as a best-effort
|
|
34
|
+
signal that only the UI path sets.
|
|
35
|
+
|
|
36
|
+
**Primary approach** (by ApiName — reliable after both the deploy and the UI paths):
|
|
37
|
+
```bash
|
|
38
|
+
sf data query -q "SELECT Id, ApiName, IsActive FROM FlowDefinitionView WHERE ApiName='Process_Field_Update_Suggestions' AND IsTemplate=false" --target-org pipeline-mgmt-org --json 2>/dev/null
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Supplementary approach** (by `SourceTemplateId` — matches only UI "Save As" clones, empty after a Metadata-API deploy):
|
|
42
|
+
```bash
|
|
43
|
+
sf data query -q "SELECT Id, ApiName, IsActive FROM FlowDefinitionView WHERE SourceTemplateId='sales_pipe_mgmt__OppSuggGenSchFlow' AND IsTemplate=false" --target-org pipeline-mgmt-org --json 2>/dev/null
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Incorrect approach** (label-based):
|
|
47
|
+
```bash
|
|
48
|
+
# DO NOT USE — fragile, language-dependent
|
|
49
|
+
sf data query -q "SELECT Id, ApiName, IsActive FROM FlowDefinitionView WHERE IsTemplate=false AND Label LIKE '%Field Update%'" --target-org pipeline-mgmt-org --json 2>/dev/null
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Why label-based detection fails**:
|
|
53
|
+
- Labels can be changed by admins
|
|
54
|
+
- Labels are translated in multi-language orgs
|
|
55
|
+
- Multiple flows could have similar labels
|
|
56
|
+
- Not the intended API design
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Clone Approach
|
|
61
|
+
|
|
62
|
+
Two methods are available:
|
|
63
|
+
|
|
64
|
+
1. **Primary — Deploy pre-retrieved template** (fully automated via `scripts/create-flow.sh`)
|
|
65
|
+
2. **Fallback — Setup UI "Save As"** (if deploy fails due to org-specific constraints)
|
|
66
|
+
3. **Verify** the clone exists and has `SourceTemplateId` set
|
|
67
|
+
4. **Activate** if saved as Draft (via retrieve → transform status → deploy)
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Method 1: Deploy Pre-Retrieved Template (PRIMARY)
|
|
72
|
+
|
|
73
|
+
The skill includes a complete flow template retrieved from a live org (`assets/pipeline_management_flow.flow-meta.xml`, 548 lines, API v67.0). This template:
|
|
74
|
+
- Contains all flow elements, connectors, action calls, variables, and schedule trigger
|
|
75
|
+
- Includes `<sourceTemplate>sales_pipe_mgmt__OppSuggGenSchFlow</sourceTemplate>` in the flow body (records provenance in the metadata; note this does **not** populate the queryable `FlowDefinitionView.SourceTemplateId` — detect the clone by ApiName, see "Flow Detection" above)
|
|
76
|
+
- Sets `<status>Active</status>` — deploys ready to run
|
|
77
|
+
- Uses `getOrExecFieldUpdtSuggestion` action type with correct input parameters
|
|
78
|
+
|
|
79
|
+
**Usage:**
|
|
80
|
+
```bash
|
|
81
|
+
bash scripts/create-flow.sh <org-alias>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**What it does:**
|
|
85
|
+
1. Checks if a clone already exists (by SourceTemplateId or naming convention)
|
|
86
|
+
2. If missing: copies template to `force-app/main/default/flows/`, updates `startDate` to today
|
|
87
|
+
3. Deploys via `sf project deploy start`
|
|
88
|
+
4. If deploy fails: falls back to Setup UI guidance
|
|
89
|
+
|
|
90
|
+
**Why this works**: While you cannot RETRIEVE the managed template via API, you CAN deploy a flow that references it as `sourceTemplate`. The platform accepts the deployment because the flow body is valid metadata — the namespace protection only blocks reads, not writes of clones.
|
|
91
|
+
|
|
92
|
+
**When deploy may fail:**
|
|
93
|
+
- Org has flow governance rules blocking new Active schedule-triggered flows
|
|
94
|
+
- API version mismatch (template uses v67.0; org may be on older API)
|
|
95
|
+
- Missing prerequisites (Pipeline Management not enabled, template not provisioned)
|
|
96
|
+
- Permission issues (user lacks `ManageFlows` permission)
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Method 2: Setup UI "Save As" (FALLBACK)
|
|
101
|
+
|
|
102
|
+
If the programmatic deploy fails, the Setup UI method always works:
|
|
103
|
+
|
|
104
|
+
1. Setup → Flows → Find "Process Field Update Suggestions" (template, marked with template icon)
|
|
105
|
+
2. Open the flow → Click **"Save As"** → New label: "Process Field Update Suggestions" → Save
|
|
106
|
+
3. The platform creates a full copy with all flow elements, connectors, and action calls intact
|
|
107
|
+
4. **Activate** the new flow (it saves as Draft by default)
|
|
108
|
+
5. The platform sets `SourceTemplateId` automatically on the clone
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Why Direct Template Retrieval Fails (Reference)
|
|
113
|
+
|
|
114
|
+
**Critical finding (verified)**: The template flow `sales_pipe_mgmt__OppSuggGenSchFlow` is in a managed namespace. **Neither programmatic retrieval method works**:
|
|
115
|
+
|
|
116
|
+
- **CLI retrieve**: `sf project retrieve start --metadata "Flow:sales_pipe_mgmt__OppSuggGenSchFlow"` → FAILS with "Entity of type 'Flow' named 'sales_pipe_mgmt__OppSuggGenSchFlow' cannot be found"
|
|
117
|
+
- **SOAP readMetadata**: Returns `<records xsi:nil="true"/>` — the managed package prevents metadata reads even with a valid session
|
|
118
|
+
|
|
119
|
+
Both methods were tested against a real org (orgfarm-88724451ea, API v64.0). This is by design — managed namespace flows are protected from external metadata reads.
|
|
120
|
+
|
|
121
|
+
**However**, the pre-retrieved template approach works because:
|
|
122
|
+
1. We retrieved the flow from a live org where it was ALREADY CLONED (user-space clone is readable)
|
|
123
|
+
2. Deploying a flow with `<sourceTemplate>` is a write operation — not subject to managed namespace read protection
|
|
124
|
+
3. The deployed flow registers correctly with `SourceTemplateId` for future detection
|
|
125
|
+
|
|
126
|
+
### What the template contains
|
|
127
|
+
|
|
128
|
+
- Flow metadata (`<fullName>`, `<label>`, `<status>`, `<isTemplate>`)
|
|
129
|
+
- All flow elements (`<actionCalls>`, `<assignments>`, `<decisions>`, `<loops>`, etc.)
|
|
130
|
+
- All connectors (`<connector>` with `<targetReference>`)
|
|
131
|
+
- All variable declarations
|
|
132
|
+
- Schedule configuration (`<startDate>`, `<frequency>`)
|
|
133
|
+
- Action call parameters (`getOrExecFieldUpdtSuggestion` with `recordId`, `fieldApiNames`, `agentUserId`, `agentBotDefinitionId`)
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Step 2: Transform the XML
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
TEMPLATE_FILE="force-app/main/default/flows/sales_pipe_mgmt__OppSuggGenSchFlow.flow-meta.xml"
|
|
141
|
+
NEW_FILE="force-app/main/default/flows/Process_Field_Update_Suggestions.flow-meta.xml"
|
|
142
|
+
|
|
143
|
+
# Copy template to new file
|
|
144
|
+
cp "$TEMPLATE_FILE" "$NEW_FILE"
|
|
145
|
+
|
|
146
|
+
# Transform metadata (macOS sed syntax — use sed -i '' on macOS, sed -i on Linux)
|
|
147
|
+
# 1. Rename the flow
|
|
148
|
+
sed -i '' 's|<fullName>sales_pipe_mgmt__OppSuggGenSchFlow</fullName>|<fullName>Process_Field_Update_Suggestions</fullName>|g' "$NEW_FILE"
|
|
149
|
+
|
|
150
|
+
# 2. Change the top-level flow label ONLY (first occurrence; non-greedy to avoid corrupting nested element labels)
|
|
151
|
+
sed -i '' '0,/<label>[^<]*<\/label>/s|<label>[^<]*</label>|<label>Process Field Update Suggestions</label>|' "$NEW_FILE"
|
|
152
|
+
|
|
153
|
+
# 3. Mark as non-template
|
|
154
|
+
sed -i '' 's|<isTemplate>true</isTemplate>|<isTemplate>false</isTemplate>|g' "$NEW_FILE"
|
|
155
|
+
|
|
156
|
+
# 4. Activate (handle both Draft and Obsolete status)
|
|
157
|
+
sed -i '' 's|<status>Draft</status>|<status>Active</status>|g' "$NEW_FILE"
|
|
158
|
+
sed -i '' 's|<status>Obsolete</status>|<status>Active</status>|g' "$NEW_FILE"
|
|
159
|
+
|
|
160
|
+
# 5. Set schedule start date to today
|
|
161
|
+
TODAY=$(date +%Y-%m-%d)
|
|
162
|
+
sed -i '' "s|<startDate>[^<]*</startDate>|<startDate>${TODAY}</startDate>|g" "$NEW_FILE"
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**What NOT to change**:
|
|
166
|
+
- Namespace-prefixed references (`sales_pipe_mgmt__*`) — these remain valid in the clone
|
|
167
|
+
- Action type (`getOrExecFieldUpdtSuggestion`) — preserved automatically
|
|
168
|
+
- Action parameters (`recordId`, `fieldApiNames`, etc.) — preserved automatically
|
|
169
|
+
- Flow elements and connectors — preserved automatically
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Step 3: Deploy the Cloned Flow
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
sf project deploy start --metadata "Flow:Process_Field_Update_Suggestions" --target-org $ORG --json 2>/dev/null
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Why deployment works**: The transformed XML is a valid Flow metadata file with:
|
|
180
|
+
- Unique `<fullName>` (no conflict with template)
|
|
181
|
+
- `<isTemplate>false</isTemplate>` (so it's a real flow, not a template)
|
|
182
|
+
- `<status>Active</status>` (so it runs immediately)
|
|
183
|
+
- All namespace-prefixed references intact (so action calls work)
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Verification
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
# Check that flow exists and is active — query by ApiName (reliable after a
|
|
191
|
+
# Metadata-API deploy, which does NOT populate SourceTemplateId).
|
|
192
|
+
sf data query -q "SELECT Id, ApiName, IsActive, SourceTemplateId FROM FlowDefinitionView WHERE ApiName='Process_Field_Update_Suggestions' AND IsTemplate=false" --target-org $ORG --json 2>/dev/null
|
|
193
|
+
|
|
194
|
+
# Expected output (SourceTemplateId is typically null after a Metadata-API deploy):
|
|
195
|
+
# {
|
|
196
|
+
# "status": 0,
|
|
197
|
+
# "result": {
|
|
198
|
+
# "records": [
|
|
199
|
+
# {
|
|
200
|
+
# "Id": "...",
|
|
201
|
+
# "ApiName": "Process_Field_Update_Suggestions",
|
|
202
|
+
# "IsActive": true,
|
|
203
|
+
# "SourceTemplateId": null
|
|
204
|
+
# }
|
|
205
|
+
# ],
|
|
206
|
+
# "totalSize": 1
|
|
207
|
+
# }
|
|
208
|
+
# }
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Key indicators of success**:
|
|
212
|
+
- `IsActive: true` — Flow is running
|
|
213
|
+
- `totalSize: 1` — Exactly one clone named `Process_Field_Update_Suggestions`
|
|
214
|
+
- `SourceTemplateId` — populated only for UI "Save As" clones; **expect `null` after a Metadata-API deploy** (does not indicate failure)
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Complete Script: Detect + Verify + Activate
|
|
219
|
+
|
|
220
|
+
The PRIMARY path deploys the pre-retrieved template automatically (Method 1). This script handles detection and post-clone verification/activation; it only prompts for the Setup UI "Save As" fallback if no clone is found (i.e. the deploy was skipped or failed).
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
#!/bin/bash
|
|
224
|
+
set -euo pipefail
|
|
225
|
+
|
|
226
|
+
ORG="${1:-pipeline-mgmt-org}"
|
|
227
|
+
|
|
228
|
+
echo "=== Checking if template clone already exists ==="
|
|
229
|
+
CLONE_QUERY=$(sf data query -q "SELECT Id, ApiName, IsActive, SourceTemplateId FROM FlowDefinitionView WHERE SourceTemplateId='sales_pipe_mgmt__OppSuggGenSchFlow' AND IsTemplate=false" --target-org "$ORG" --json 2>/dev/null)
|
|
230
|
+
|
|
231
|
+
CLONE_COUNT=$(echo "$CLONE_QUERY" | jq -r '.result.totalSize // 0')
|
|
232
|
+
|
|
233
|
+
if [[ "$CLONE_COUNT" -eq 0 ]]; then
|
|
234
|
+
# Fallback: check by naming convention
|
|
235
|
+
CLONE_QUERY=$(sf data query -q "SELECT Id, ApiName, IsActive FROM FlowDefinitionView WHERE ApiName LIKE '%OppSuggGen%' AND IsTemplate=false" --target-org "$ORG" --json 2>/dev/null)
|
|
236
|
+
CLONE_COUNT=$(echo "$CLONE_QUERY" | jq -r '.result.totalSize // 0')
|
|
237
|
+
fi
|
|
238
|
+
|
|
239
|
+
if [[ "$CLONE_COUNT" -eq 0 ]]; then
|
|
240
|
+
echo "No template clone found."
|
|
241
|
+
echo ""
|
|
242
|
+
echo "ACTION REQUIRED: Clone the template flow manually via Setup UI:"
|
|
243
|
+
echo " 1. Setup → Flows → Find 'Process Field Update Suggestions' (template)"
|
|
244
|
+
echo " 2. Open the flow → Save As → Label: 'Process Field Update Suggestions' → Save"
|
|
245
|
+
echo " 3. Activate the new flow"
|
|
246
|
+
echo " 4. Re-run this script to verify"
|
|
247
|
+
echo ""
|
|
248
|
+
echo "NOTE: Programmatic retrieval of managed namespace flows is not possible."
|
|
249
|
+
echo " - CLI retrieve returns: 'Entity of type Flow cannot be found'"
|
|
250
|
+
echo " - SOAP readMetadata returns: <records xsi:nil=\"true\"/>"
|
|
251
|
+
exit 1
|
|
252
|
+
fi
|
|
253
|
+
|
|
254
|
+
echo "Found $CLONE_COUNT clone(s):"
|
|
255
|
+
echo "$CLONE_QUERY" | jq '.result.records[] | {ApiName, IsActive, SourceTemplateId}'
|
|
256
|
+
echo ""
|
|
257
|
+
|
|
258
|
+
# Check if active
|
|
259
|
+
IS_ACTIVE=$(echo "$CLONE_QUERY" | jq -r '.result.records[0].IsActive')
|
|
260
|
+
FLOW_API_NAME=$(echo "$CLONE_QUERY" | jq -r '.result.records[0].ApiName')
|
|
261
|
+
|
|
262
|
+
if [[ "$IS_ACTIVE" == "true" ]]; then
|
|
263
|
+
echo "Flow '$FLOW_API_NAME' is ACTIVE. Suggestions will generate on schedule."
|
|
264
|
+
echo ""
|
|
265
|
+
echo "=== Done ==="
|
|
266
|
+
exit 0
|
|
267
|
+
fi
|
|
268
|
+
|
|
269
|
+
echo "Flow '$FLOW_API_NAME' exists but is INACTIVE. Attempting activation..."
|
|
270
|
+
echo ""
|
|
271
|
+
|
|
272
|
+
# Activate via retrieve → transform → deploy
|
|
273
|
+
sf project retrieve start --metadata "Flow:${FLOW_API_NAME}" --target-org "$ORG" --json 2>/dev/null >/dev/null || true
|
|
274
|
+
|
|
275
|
+
FLOW_FILE="force-app/main/default/flows/${FLOW_API_NAME}.flow-meta.xml"
|
|
276
|
+
|
|
277
|
+
if [[ -f "$FLOW_FILE" ]]; then
|
|
278
|
+
# Cross-platform sed in-place
|
|
279
|
+
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
280
|
+
sed -i '' 's|<status>Draft</status>|<status>Active</status>|g' "$FLOW_FILE"
|
|
281
|
+
sed -i '' 's|<status>Obsolete</status>|<status>Active</status>|g' "$FLOW_FILE"
|
|
282
|
+
else
|
|
283
|
+
sed -i 's|<status>Draft</status>|<status>Active</status>|g' "$FLOW_FILE"
|
|
284
|
+
sed -i 's|<status>Obsolete</status>|<status>Active</status>|g' "$FLOW_FILE"
|
|
285
|
+
fi
|
|
286
|
+
|
|
287
|
+
DEPLOY_RESULT=$(sf project deploy start --metadata "Flow:${FLOW_API_NAME}" --target-org "$ORG" --json 2>/dev/null)
|
|
288
|
+
|
|
289
|
+
if echo "$DEPLOY_RESULT" | jq -e '.status == 0' >/dev/null 2>&1; then
|
|
290
|
+
echo "Flow activated successfully via Metadata API deploy."
|
|
291
|
+
else
|
|
292
|
+
echo "Warning: Deploy returned non-zero status. Check flow in Setup → Flows."
|
|
293
|
+
echo "$DEPLOY_RESULT" | jq '.message // .result.details.componentFailures[0].problem // "unknown error"' 2>/dev/null || true
|
|
294
|
+
fi
|
|
295
|
+
else
|
|
296
|
+
echo "Warning: Could not retrieve flow metadata for activation."
|
|
297
|
+
echo "Activate manually: Setup → Flows → ${FLOW_API_NAME} → Activate"
|
|
298
|
+
fi
|
|
299
|
+
|
|
300
|
+
echo ""
|
|
301
|
+
|
|
302
|
+
# Final verification
|
|
303
|
+
echo "=== Final verification ==="
|
|
304
|
+
sf data query -q "SELECT ApiName, IsActive FROM FlowDefinitionView WHERE ApiName='${FLOW_API_NAME}'" --target-org "$ORG" --json 2>/dev/null | jq '.result.records[0] | {ApiName, IsActive}'
|
|
305
|
+
|
|
306
|
+
echo ""
|
|
307
|
+
echo "=== Done ==="
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## Understanding the Flow Action Type
|
|
313
|
+
|
|
314
|
+
The cloned flow uses the `getOrExecFieldUpdtSuggestion` action type (NOT `generatePromptResponse`). This action:
|
|
315
|
+
- Takes inputs: `recordId`, `fieldApiNames`, `agentUserId`, `agentBotDefinitionId`
|
|
316
|
+
- Generates field update suggestions via prompt templates
|
|
317
|
+
- Stores results as `AiGenActionItem` records (`Type = 'FIELD_UPDATE'`, `Subject` = the field API name, `ParentId` = the Opportunity Id)
|
|
318
|
+
|
|
319
|
+
**Why you don't need to know this**: The template already has the correct action type configured. When you clone it, you preserve the entire action call structure — no manual construction needed.
|
|
320
|
+
|
|
321
|
+
**What happens if you try to build from scratch**:
|
|
322
|
+
- You'd need to know the exact action name (`getOrExecFieldUpdtSuggestion`)
|
|
323
|
+
- You'd need to know the exact input parameter names and types
|
|
324
|
+
- You'd need to know the namespace prefix for prompt template references
|
|
325
|
+
- You'd risk getting any of these wrong and producing a non-functional flow
|
|
326
|
+
|
|
327
|
+
**The clone approach avoids all of this** — the template is the source of truth.
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## Namespace-Prefixed References
|
|
332
|
+
|
|
333
|
+
The template flow references prompt templates with namespace prefixes:
|
|
334
|
+
- `sales_pipe_mgmt__RecommendStageforOpp`
|
|
335
|
+
- `sales_pipe_mgmt__RecommendNextStepforOpp`
|
|
336
|
+
|
|
337
|
+
**Do NOT strip these prefixes** — they're required even in the cloned flow. The namespace prefix is how Salesforce identifies these as Pipeline Management provisioned templates (not user-created custom templates).
|
|
338
|
+
|
|
339
|
+
**Why this works in the clone**: When you deploy the transformed XML with these references intact, Salesforce validates that:
|
|
340
|
+
1. The referenced prompt templates exist in the org
|
|
341
|
+
2. They were provisioned with the `sales_pipe_mgmt__` namespace
|
|
342
|
+
3. They're active and available
|
|
343
|
+
|
|
344
|
+
If you strip the namespace prefixes, the references break and the flow fails validation.
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## Troubleshooting
|
|
349
|
+
|
|
350
|
+
### Template doesn't exist
|
|
351
|
+
|
|
352
|
+
**Symptom**: `sf project retrieve start` fails with "No source-backed components present"
|
|
353
|
+
|
|
354
|
+
**Cause**: Pipeline Management is not enabled or template hasn't been provisioned yet
|
|
355
|
+
|
|
356
|
+
**Fix**:
|
|
357
|
+
```bash
|
|
358
|
+
# Verify Pipeline Management is enabled
|
|
359
|
+
curl -s "${INSTANCE_URL}/services/Soap/m/64.0" \
|
|
360
|
+
-H "Content-Type: text/xml; charset=UTF-8" \
|
|
361
|
+
-H "SOAPAction: readMetadata" \
|
|
362
|
+
-d "<?xml version='1.0' encoding='utf-8'?>
|
|
363
|
+
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:met='http://soap.sforce.com/2006/04/metadata'>
|
|
364
|
+
<soapenv:Header><met:SessionHeader><met:sessionId>${ACCESS_TOKEN}</met:sessionId></met:SessionHeader></soapenv:Header>
|
|
365
|
+
<soapenv:Body><met:readMetadata>
|
|
366
|
+
<met:type>SalesDealAgentSettings</met:type>
|
|
367
|
+
<met:fullNames>SalesDealAgent</met:fullNames>
|
|
368
|
+
</met:readMetadata></soapenv:Body>
|
|
369
|
+
</soapenv:Envelope>" | grep -o "<enableDealAgent>[^<]*</enableDealAgent>"
|
|
370
|
+
|
|
371
|
+
# Expected: <enableDealAgent>true</enableDealAgent>
|
|
372
|
+
# If false: Enable Pipeline Management first (see references/setup-order.md)
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Deploy fails with validation errors
|
|
376
|
+
|
|
377
|
+
**Symptom**: Deploy reports errors about missing prompt templates or invalid action types
|
|
378
|
+
|
|
379
|
+
**Cause**: Namespace-prefixed references were removed or template was modified incorrectly
|
|
380
|
+
|
|
381
|
+
**Fix**:
|
|
382
|
+
1. Re-retrieve the template (don't use a cached copy)
|
|
383
|
+
2. Only transform the metadata fields listed in Step 2 — don't modify flow elements
|
|
384
|
+
3. Check that namespace prefixes are intact (`grep "sales_pipe_mgmt__" "$NEW_FILE"`)
|
|
385
|
+
|
|
386
|
+
### Flow deploys but doesn't run
|
|
387
|
+
|
|
388
|
+
**Symptom**: Flow exists, `IsActive: true`, but no suggestions generated
|
|
389
|
+
|
|
390
|
+
**Cause**: Missing prerequisites (agent not active, stage descriptions missing, no data sources)
|
|
391
|
+
|
|
392
|
+
**Fix**: See `references/repair-diagnostics.md` for full checklist
|
|
393
|
+
|
|
394
|
+
### Clone already exists
|
|
395
|
+
|
|
396
|
+
**Symptom**: Deploy fails with "A flow with this name already exists"
|
|
397
|
+
|
|
398
|
+
**Cause**: Flow was already cloned
|
|
399
|
+
|
|
400
|
+
**Fix**:
|
|
401
|
+
```bash
|
|
402
|
+
# Check existing flow status
|
|
403
|
+
sf data query -q "SELECT Id, ApiName, IsActive FROM FlowDefinitionView WHERE SourceTemplateId='sales_pipe_mgmt__OppSuggGenSchFlow' AND IsTemplate=false" --target-org $ORG --json 2>/dev/null
|
|
404
|
+
|
|
405
|
+
# If IsActive: false → reactivate via Tooling API
|
|
406
|
+
FLOW_ID=$(sf data query -q "SELECT Id FROM FlowDefinitionView WHERE SourceTemplateId='sales_pipe_mgmt__OppSuggGenSchFlow' AND IsTemplate=false" --target-org $ORG --json 2>/dev/null | jq -r '.result.records[0].Id')
|
|
407
|
+
|
|
408
|
+
curl -X PATCH "${INSTANCE_URL}/services/data/v64.0/tooling/sobjects/Flow/${FLOW_ID}" \
|
|
409
|
+
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
|
|
410
|
+
-H "Content-Type: application/json" \
|
|
411
|
+
-d '{"Metadata":{"status":"Active"}}' 2>/dev/null
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## Setup UI Quick Reference (Fallback only)
|
|
417
|
+
|
|
418
|
+
Deploying the pre-retrieved template (Method 1, PRIMARY) is fully automated and is what
|
|
419
|
+
`scripts/create-flow.sh` / `setup-all.sh` use. The Setup UI "Save As" below is the **fallback**
|
|
420
|
+
for the rare org where the programmatic deploy fails on org-specific constraints:
|
|
421
|
+
|
|
422
|
+
1. Go to Setup → Flows → Find "Process Field Update Suggestions" (look for template icon)
|
|
423
|
+
2. Open the flow → **Save As** → Label: "Process Field Update Suggestions" → Save
|
|
424
|
+
3. **Activate** the new flow
|
|
425
|
+
4. Verify: Run the detection query from "Flow Detection" section above
|
|
426
|
+
|
|
427
|
+
**Limitations of the UI fallback**:
|
|
428
|
+
- Requires manual interaction (not fully automatable)
|
|
429
|
+
- Cannot be batched across multiple orgs via script
|
|
430
|
+
- Requires System Administrator access to Setup → Flows
|
|
431
|
+
|
|
432
|
+
**What is automatable after a manual fallback clone**:
|
|
433
|
+
- Detection (query `SourceTemplateId` to confirm clone exists)
|
|
434
|
+
- Activation (Tooling API PATCH if saved as Draft)
|
|
435
|
+
- Verification (query `IsActive` status)
|
|
436
|
+
- Schedule configuration (deploy modified flow XML after initial clone)
|
|
437
|
+
|
|
438
|
+
---
|
|
439
|
+
|
|
440
|
+
## Notes
|
|
441
|
+
|
|
442
|
+
- Always use `2>/dev/null` on `sf ... --json` piped to jq
|
|
443
|
+
- Flow detection uses `SourceTemplateId` (NOT label-based)
|
|
444
|
+
- Clone preserves `getOrExecFieldUpdtSuggestion` action type automatically
|
|
445
|
+
- Namespace-prefixed references must remain intact
|
|
446
|
+
- Pipeline Management generates NO suggestions until this flow is active
|
|
447
|
+
- Template is provisioned on Pipeline Management enablement but never self-activates
|