Skip to content

forcedotcom/sf-skills / skills/consumer-goods-promotion-bo-api-deploy

consumer-goods-promotion-bo-api-deploy

Verified

Use to enable the Consumer Goods Cloud TPM Promotion Business Object (BO) API framework in a Salesforce org, interview the user for the custom Workflow Step they want to add, generate and deploy that Apex class, wire it into the create/update/copy workflows, and prove it end-to-end via headless REST ingest. Ships a worked reference example (SetCommentValue) but the customization is user-supplied per org. Triggers on "deploy the promotion BO API", "set up promotion BO API", "headless promotion create", "add a BO API workflow step".

references/reference-example-set-comment-value.md

View on GitHub
# Reference example — `SetCommentValue`

One worked customization the skill ships as a preset. It exists so a reviewer can
see a complete, verified answer to the Phase 5 interview. The skill does not
deploy it by default — the customer picks it explicitly via
`--preset set-comment-value` or by saying "use the SetCommentValue reference"
during the interview. All files below ship under
`assets/set-comment-value/`.

## Interview answers

```json
{
  "stepName": "SetCommentValue",
  "entity": "Tactic",
  "workflows": ["create", "update", "copy"],
  "actionName": "setCommentValue",
  "inputPaths": ["Comment"],
  "outputWrites": [
    { "field": "Comment__c", "source": "Comment" }
  ],
  "description": "Copies the tactic input Comment to Tactic.Comment__c.",
  "preconditions": null,
  "sortAfter": null
}
```

Ships at `assets/set-comment-value/interview-answers.json`.

## Generated class

The class is namespace-agnostic — it works whether the target org has `cgcloud`,
`cgcloud_dev`, or no prefix, because it derives the Tactic namespace from the
passed SObject at runtime and never types `<ns>__Tactic__c` or `<ns>__Comment__c`
at compile time. Context-key names (`currentInput`, `currentOutput`) are the ones
the packaged `BoTransformationEngine` seeds — verified at lines 825–864 of
`BoTransformationEngine.cls`. Ships at
`assets/set-comment-value/SetCommentValue.cls`.

```apex
/**
 * Custom BO API Workflow Step: lifts a top-level `Comment` value out of
 * the ingest tactic input onto Tactic.Comment__c.
 *
 * Registered against the `Tactic` BO API entity and wired into the
 * `create`, `update`, and `copy` workflows.
 */
global with sharing class SetCommentValue implements Callable {

  public class SetCommentValueException extends Exception {}

  // global (not public): the packaged CallableManager must resolve/invoke this
  // subscriber Callable across the namespace boundary on a managed-installed org
  // (a public class fails at runtime with `Type "SetCommentValue" does not exist`).
  global Object call(String action, Map<String, Object> context) {
    if (action != 'setCommentValue') {
      throw new SetCommentValueException('Unsupported action: ' + action);
    }
    if (context == null) {
      throw new SetCommentValueException('null context');
    }

    Object rawInput = context.get('currentInput');
    Object rawOutput = context.get('currentOutput');

    if (!(rawInput instanceof Map<String, Object>)) {
      return null;
    }
    Map<String, Object> tacticInput = (Map<String, Object>) rawInput;
    Object commentValue = tacticInput.get('Comment');
    if (commentValue == null) {
      return null;
    }

    // The engine wraps Tactic__c in TPM_Promotion.TacticRecord (see
    // BoTransformationEngineEntityTree.generateObject:696 —
    //   promo.addTactic(new Tactic__c()) returns a TacticRecord wrapper).
    // Unwrap to the underlying SObject via getRecord() before writing;
    // a raw SObject cast fails silently and the write never persists.
    SObject tactic;
    if (rawOutput instanceof SObject) {
      tactic = (SObject) rawOutput;
    } else if (rawOutput instanceof TPM_Promotion.Record) {
      tactic = ((TPM_Promotion.Record) rawOutput).getRecord();
    } else {
      return null;
    }

    String tacticType = String.valueOf(tactic.getSObjectType());
    String prefix = '';
    if (tacticType.contains('__') && tacticType.endsWith('__c')) {
      Integer firstUnderscoreUnderscore = tacticType.indexOf('__');
      Integer lastUnderscoreUnderscore = tacticType.lastIndexOf('__');
      if (firstUnderscoreUnderscore < lastUnderscoreUnderscore) {
        prefix = tacticType.substring(0, firstUnderscoreUnderscore) + '__';
      }
    }

    tactic.put(prefix + 'Comment__c', String.valueOf(commentValue));
    return null;
  }
}
```

## Class metadata

Ships at `assets/set-comment-value/SetCommentValue.cls-meta.xml`.

```xml
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>60.0</apiVersion>
    <status>Active</status>
</ApexClass>
```

## Reference payloads

Live at `assets/set-comment-value/payloads/`:
- `create.json` — sets `Comment` on a new promotion's tactic.
- `update.json` — updates the tactic's `Comment`.
- `copy.json` — copies the source promotion; expects the tactic's `Comment` to be carried across.

Each carries the `REPLACED-AT-RUNTIME` marker for `importId` (and, for
`update`/`copy`, marker ids for the promotion + tactic captured from the
preceding response).

## Expected write

`Tactic__c.Comment__c` on the created / updated / copied promotion's tactic must
equal the `Comment` value from the corresponding payload — this is the
interview's single `outputWrites` assertion.
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall