forcedotcom/sf-skills / plugins/builder/consumer-goods/skills/consumer-goods-rtr-datacloud-export-configure
consumer-goods-rtr-datacloud-export-configure
VerifiedConfigure a Trade Promotion Management (TPM) org's RTR (Real Time Reporting) export pipeline to push promotion measures into Data Cloud (Data 360) for Trade Promotion Effectiveness (TPE) dashboards. Use when a customer or admin wants to set up the RTR export for Data Cloud measures, configure the RTR report for TPE, or as a delegated step from consumer-goods-tpe-dashboard-configure.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 7.8 KB |
| references/inputs-and-namespace.md | markdown | 5.3 KB |
| references/procedure.md | markdown | 16.8 KB |
| scripts/detect-namespace.jsexecutable | script | 2.3 KB |
| scripts/render-apex.jsexecutable | script | 2.0 KB |
| scripts/resolve-id-by-name.jsexecutable | script | 1.5 KB |
| scripts/sf-rest.jsexecutable | script | 5.7 KB |
| scripts/soql-escape.jsexecutable | script | 882 B |
| scripts/upsert-report-config.apex | other | 2.3 KB |
| scripts/upsert-system-setting.apex | other | 722 B |
references/inputs-and-namespace.md
View on GitHub# Inputs to collect first
Ask before starting, unless already supplied by a calling skill. Do not guess any of these.
1. **TPM System Admin username** — already authenticated via `sf` CLI. Verify via the sibling script, never `sf org display --json` directly — that command's raw output includes `accessToken` (a live credential), which this script strips before printing:
```bash
node ./scripts/sf-rest.js org-status --target-org <username>
```
Prints `{"username","alias","connectedStatus","orgId"}`. Non-zero exit or `connectedStatus != "Connected"` ⇒ stop, ask the user to log in themselves.
2. **Dry-run?** — offer by default. In dry-run, every read/verify step still runs; every write/trigger step is skipped and recorded as `pending — not run (dry-run)`.
3. **GenieAdmin confirmation** — if invoked standalone, query it directly (see Phase 1 in `references/procedure.md`); if invoked by `consumer-goods-tpe-dashboard-configure`, use its passed-through result instead of re-querying.
4. **"TPM Admin" permission-set confirmation** — org-specific, cannot be verified programmatically. Ask directly if run standalone; if invoked by `consumer-goods-tpe-dashboard-configure`, use its passed-through confirmation.
5. **Namespace (`NS`)** — if invoked by `consumer-goods-tpe-dashboard-configure`, use its passed-through `NS` (raw namespace string, already detected once for the whole run — never re-detect). If run standalone, detect it once yourself, before Phase 1 (see "Namespace detection" below).
Do **not** ask for anything below yet. None of these are collected up front — Phase 6 asks for the Sales Org Name itself as its first step of each loop iteration, then checks for an existing `RTR_Report_Configuration__c` before asking for the rest:
6. **Sales Org** — a `Sales_Organization__c` **Name**, provided directly by the user; the skill resolves it to an Id by query (Phase 6 step 1). Phase 6 processes Sales Orgs one at a time, asking for this Name at the start of each loop iteration and asking whether to add another after each one finishes.
7. **KPI Set** — the **Name** of an existing `KPI_Set__c`, provided by the user; the skill resolves it to an Id by query (Phase 6 step 3). This skill never creates a KPI Set — customers set up their `KPI_Set__c` and its `KPI_Set_KPI_Definition__c` junction rows independently, outside this skill.
8. **Measure codes** — the KPI Definition measure codes to export, not Names. These are pure user input, exactly like Sales Org and KPI Set above — never propose, default, or pre-select any codes yourself, even as an "example" answer option. Once the KPI Set is resolved in Phase 6 step 3, query that KPI Set's junction rows, filtered to writeback-eligible KPI Definitions only (`NS_FIELD` throughout):
```bash
sf data query --target-org <username> \
--query "SELECT <NS_FIELD>KPI_Definition__r.Name, <NS_FIELD>KPI_Definition__r.<NS_FIELD>Storage_Options_Measure_Code__c FROM <NS_FIELD>KPI_Set_KPI_Definition__c WHERE <NS_FIELD>KPI_Set__c = '<kpiSetId>' AND <NS_FIELD>KPI_Definition__r.<NS_FIELD>Storage_Options_Writeback__c = true"
```
Zero rows ⇒ stop and tell the user this KPI Set has no writeback-eligible KPI Definitions (none with `Storage_Options_Writeback__c = true`); they need to enable writeback on at least one KPI Definition in the set before this export can be configured. Otherwise, show the user the resulting list of `{Name, Storage_Options_Measure_Code__c}` pairs and ask: *"Export all N writeback-eligible KPIs listed above, or a specific subset? Note: the amount of data exported is proportional to the number of KPIs selected — fewer codes means a smaller, faster export."* "All" ⇒ use every `Storage_Options_Measure_Code__c` from the list. Subset ⇒ let the user pick specific Names/codes from that same list — never accept a code that didn't appear in the query result. Used only to populate `JSON__c`'s `measurecodes` list; not used to build junction rows.
9. **Date-from** — export start date, `YYYY-MM-DD`.
## Namespace detection (standalone runs only — skip if `NS` was passed in)
Same canonical procedure as `consumer-goods-tpe-dashboard-configure`'s "Namespace detection" step (package-installed lookup, falling back to `sf org display`'s `result.namespace`, falling back to `""`) — never re-derive a different way. Run the sibling script, which does all three steps and the `NS_*` derivations in one call:
```bash
node ./scripts/detect-namespace.js --target-org <username>
```
Prints `{"NS","NS_SEGMENT","NS_APEX","NS_FIELD"}` as one line of JSON. Store all four and reuse everywhere below:
- `NS` — raw namespace string (may be empty).
- `NS_SEGMENT` — REST URL path segment: `"<NS>/"` if `NS` is non-empty, else `""`. Insert immediately after `/services/apexrest/`.
- `NS_APEX` — Apex class-reference prefix: `"<NS>."` if `NS` is non-empty, else `""`. Prefix every reference to a class from this package (`OffPlatformCallout`, `OffPlatformCalloutResponse`, `TransactionHandler`, `RTRSyncReportConfigInvocable`) with this.
- `NS_FIELD` — custom object/field API-name prefix: `"<NS>__"` if `NS` is non-empty, else `""`. Prefix every custom object and custom field API name (standard fields like `Id`/`Name` never take this prefix) with this, in SOQL, `sf sobject describe`/`sf data upsert` commands, and Apex sObject type declarations alike.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 119k | Updated | Claude CodeCodex | Verified | Install |
| 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: 118k | Updated | Claude CodeCodex | Verified | Install |