forcedotcom/sf-skills

life-sciences-territory-configure

Use this skill to create and activate a Territory Type, Territory Model, and Territories for Life Sciences Cloud.

Vedi sorgente
Documento Skill originale

Contenuto dal repository con titoli, esempi, codice, tabelle, link e immagini preservati.

Life Sciences Territory Setup

Creates and activates a Territory Type, Territory Model, and a 3-level Territory hierarchy for Life Sciences Cloud using the sf CLI.

Scope

  • In scope: Creating territory type, territory model, and territories; activating the territory model
  • Out of scope: Assigning users to territories, creating territory assignment rules, validating prerequisites

Off-topic requests

If the user asks for something unrelated to this skill (either at the start or mid-execution), do not attempt it. Tell the user you did not understand the request, then show what you can help with: setting up Life Sciences Cloud territories (this skill), and — if relevant — point them to life-sciences-prerequisites-validate for prerequisite checks or life-sciences-fieldsalesrep-coordinate for the full end-to-end setup. Then stop and wait.


Required Inputs

Gather before proceeding:

  • Target org: The org alias or username to deploy to (from sf config get target-org or user-specified)

Workflow

Phase 1 — Present Default Names and Get Confirmation

  1. Show the user the default names that will be used for the territory components. Read references/territory-metadata.md for the exact XML templates and default names.

Present the names in a table:

markdown
| Component | Default Name |
|-----------|-------------|
| Territory Type | Geographical |
| Territory Model | LSC Territory Model |
| Territory (Level 1 - Region) | RD - West 20D |
| Territory (Level 2 - District) | DM - San Francisco 20D02 |
| Territory (Level 3 - Territory) | TM - SPC - San Francisco North 20D02T11 |
  1. Ask the user if they are fine with these names or want to change any of them. Ask for each component individually:
  • "Are you fine with the Territory Type name 'Geographical' or would you like to change it?"
  • "Are you fine with the Territory Model name 'LSC Territory Model' or would you like to change it?"
  • "Are you fine with the Region territory name 'RD - West 20D' or would you like to change it?"
  • "Are you fine with the District territory name 'DM - San Francisco 20D02' or would you like to change it?"
  • "Are you fine with the Territory name 'TM - SPC - San Francisco North 20D02T11' or would you like to change it?"
  1. If the user wants to change a name, ask them for the new name they'd like to use. Record the updated name.

Phase 2 — Preview and Confirm

  1. Display a complete preview of what will be created, showing the final XML for each component with the confirmed names. Use the templates from references/territory-metadata.md and substitute any user-provided names.

Show the preview in this format:

text
=== Territory Type ===
Name: <confirmed name>
Priority: 1

=== Territory Model ===
Name: <confirmed model name>

=== Territory Hierarchy ===
Level 1 (Region): <confirmed region name>
  └── Level 2 (District): <confirmed district name>
        └── Level 3 (Territory): <confirmed territory name>

Access Levels (all territories):
- Account: Read
- Contact: Edit
- Case: None
- Opportunity: None
  1. Ask for final confirmation: "Ready to create and deploy these territory components? (yes/no)"

If user says no, go back to Phase 1.

Phase 3 — Create and Deploy

  1. Create a temporary SFDX project structure for deployment. Read references/territory-metadata.md for the exact file structure and XML content.

The directory structure must be:

text
territory-deploy/
├── sfdx-project.json
└── force-app/
    └── main/
        └── default/
            └── territory2Models/
                ├── <ModelApiName>.territory2Model-meta.xml
                └── <ModelApiName>/
                    ├── territory2Types/
                    │   └── <TypeApiName>.territory2Type-meta.xml
                    └── territories/
                        ├── <Level1ApiName>.territory2-meta.xml
                        ├── <Level2ApiName>.territory2-meta.xml
                        └── <Level3ApiName>.territory2-meta.xml
  1. Generate API names from user-confirmed display names:
  • Remove special characters, spaces, and hyphens
  • Use PascalCase for the API name
  • Territory type API name is derived from the type display name
  • Territory model API name is derived from the model display name (remove spaces)
  • Territory API names are derived from territory display names (remove spaces, hyphens, special chars)
  1. Write the metadata files using the templates from references/territory-metadata.md with confirmed names.
  1. Deploy the metadata using:
bash
   sf project deploy start --source-dir territory-deploy/force-app --target-org <org>
  1. Check deployment status — if it fails, show the error and suggest remediation.
STOP-GATE (component count). The single deploy package must land the complete hierarchy: 1 Territory2Type + 1 Territory2Model + 3 Territory2 records (one Region, one District, one Territory). Confirm the deploy result reports 0 component failures AND verify the territories exist before activating: ``bash sf data query --query "SELECT COUNT(Id) c FROM Territory2 WHERE Territory2Model.DeveloperName = '<ModelApiName>'" --target-org <org> --json `` The count MUST be 3. A parent-reference failure (e.g. the District deploying before its Region) can land a partial hierarchy — a Level-3 territory with no path to its Region silently breaks downstream user/visit territory assignment. Do NOT activate the model (Phase 4) until all 3 territories are present with 0 deploy failures.

Phase 4 — Activate Territory Model

  1. Report that the model deployed in Planning state and ask the user if they want to activate it. Include this warning:
Note: Once a Territory Model is activated, it can be deactivated but cannot be deleted. Do you want to proceed with activation?
  1. If the user confirms activation, activate the model by querying its record ID then updating its State to 'Activating' (not 'Active' — the platform transitions asynchronously from Activating → Active):
bash
    # Query the model ID and current state
    sf data query --query "SELECT Id, State FROM Territory2Model WHERE DeveloperName = '<ModelApiName>' LIMIT 1" --target-org <org> --json

If the model is in Planning state, update it:

bash
    sf data update record --sobject Territory2Model --record-id <ModelId> --values "State='Activating'" --target-org <org>

See references/territory-metadata.md for the full activation logic including error handling.

  1. Verify activation — the platform transitions asynchronously from ActivatingActive. Query to confirm:
bash
    sf data query --query "SELECT Id, DeveloperName, State FROM Territory2Model WHERE DeveloperName='<ModelApiName>'" --target-org <org>

If still Activating, wait a moment and query again until it reaches Active.

  1. If the user declines activation, report that the model is in Planning state and can be activated later from Setup.
  1. Report success — confirm to the user that all components are created, and report the model's current state (Planning, Activating, or Active).

Rules / Constraints

ConstraintRationale
Create exactly one territory per level — one Level-1 Region, one Level-2 District, one Level-3 Territory (3 territories total)Skill produces a single representative hierarchy branch, not a fully populated multi-child tree
Always confirm names before creatingUser may want to customize territory names for their org
Show preview before deployingUser should see exactly what will be created
Deploy all components togetherTerritory hierarchy has dependencies (parent references)
Warn user before activation that model cannot be deleted once activeIrreversible action — user must explicitly consent
Set State to 'Activating' (not 'Active') when updating the recordThe platform handles the async transition from Activating → Active
Target the update by --record-id <ModelId> or --where "DeveloperName='<ModelApiName>'"Both forms work for sf data update record; use whichever is convenient
Clean up temp directory after deployDon't leave deployment artifacts behind

Gotchas

IssueResolution
Territory model already exists with same nameCheck first with a query; ask user if they want a different name
Territory type already existsCheck first; reuse existing type if it matches
Deploy fails due to parent territory not foundEnsure all territories are in the same deployment package
Setting State to 'Active' directly fails with INVALID_STATUSAlways set State to 'Activating' — the platform transitions to Active asynchronously
Model state shows Activating after updateThis is normal — activation is async. Wait and re-query until Active
API name conflictsEnsure generated API names don't conflict with existing metadata

Output Expectations

Deliverables:

  • Created Territory Type with confirmed name
  • Created Territory Model with confirmed name
  • Created 3-level territory hierarchy with confirmed names
  • Territory Model activated (or manual activation steps if programmatic activation fails)
  • Confirmation message showing all created components and their status

Reference File Index

FileWhen to read
references/territory-metadata.mdDuring all phases — contains XML templates, file structure, and default values for territory components
dallo stesso repository

Altri Skills

Tutti gli Skills
forcedotcom
Community

education-cloud-multi-campus-configure

Use this skill when a Salesforce Administrator needs to create OR maintain an institutional hierarchy for Education Cloud by parsing organizational structure from a PDF, URL, text, or CSV. On a first run it creates System, Campus, College, and Department Account records linked via ParentId plus 1:1 Business Profile records. On later runs it reconciles the org's existing hierarchy against the desired structure and applies only the delta — adding new units, renaming, or moving a node under a different parent — never recreating what exists. TRIGGER when the user wants to set up, configure, build, update, restructure, or reorganize a multi-campus structure, institutional hierarchy, or account hierarchy with business profiles; or add, rename, or move a campus, college, or department. DO NOT TRIGGER for single-campus flat setups without hierarchy levels, one-off manual account creation, or non-Education-Cloud account management.

installazioni
2
GitHub Stars
976
Aggiornato
8 set
forcedotcom
Community

automation-sandbox-post-copy-config-generate

Generate the JSON config file that the Salesforce sandbox post-copy automation tool consumes, from a customer SOP in any format (PDF, xlsx, csv, JSON, docx, Markdown, plain text, or a screenshot of an endpoint table). Use when the user asks to create, build, generate, produce, or convert a post-copy or post-refresh automation config — turning a sandbox-refresh SOP into a JSON array of OutboundMessages and RemoteSiteSettings entries with ConfigurationName, Label, Fields, IsActive, and ExecutionOrder. Also trigger for phrasings like \"post-copy config\", \"post-refresh automation JSON\", \"update the outbound message (OBM) endpoints after refresh\", \"convert this SOP to config\", \"remote site settings JSON\", \"refresh planner to JSON\", or \"sandbox refresh config\". DO NOT TRIGGER when: user wants to deploy the generated config to an org (use platform-metadata-deploy), or apply/execute/run/dry-run the post-copy automation JSON against a sandbox (use automation-sandbox-post-copy-configure).

installazioni
1
GitHub Stars
976
Aggiornato
8 set
forcedotcom
Community

commerce-b2b-open-code-components-integrate

Integrate Salesforce B2B Commerce open source components from GitHub into B2B Commerce stores. Use when users mention \"integrate open code components\", \"open source B2B commerce\", \"add open code components\", \"forcedotcom/b2b-commerce-open-source-components\", or want to add open source commerce components to their store. Copies all components and labels so they become available in Experience Builder.

installazioni
1
GitHub Stars
976
Aggiornato
8 set
forcedotcom
Community

commerce-b2b-open-code-components-replace

Replace OOTB (out-of-the-box) B2B Commerce components with open source equivalents in site metadata content.json files, or look up the equivalent open code site: component for OOTB definitions. Use when users mention \"replace OOTB components\", \"replace commerce components with open code\", \"swap OOTB for open source\", \"replace commercebuilder:\", \"replace OOTB in site\", \"replace component in site metadata\", \"replace component definition\", \"find open code equivalent\", \"equivalent open code component\", \"OOTB to open code mapping\", \"what is the site component for\", components \"in this view\" or \"for a given view\", or a specific list of component names — and want to update or only discover mappings in their store metadata.

installazioni
1
GitHub Stars
976
Aggiornato
8 set