Skip to content

forcedotcom/sf-skills / plugins/builder/consumer-goods/skills/consumer-goods-tpe-dashboard-configure

consumer-goods-tpe-dashboard-configure

Verified

End-to-end headless setup of Trade Promotion Effectiveness (TPE) dashboards for a Trade Promotion Management (TPM) Cloud org, covering tenant pairing checks, permission sets, SSOT and Tableau Next enablement, C360 SDM verification, the TPM Accruals data kit install, business-period export, RTR Data Cloud export configuration, the TPM_PROMOTION_MEASURE Data Transform, TPE Analytics app install, and optional KPI dashboard customization. Use when a customer or admin wants to set up TPE dashboards, enable Trade Promotion Effectiveness, install the TPE analytics app, or set up and customize TPE dashboards with their own KPIs.

FileKindSize
SKILL.mdskill md5.7 KB
references/phases-1-6.mdmarkdown9.3 KB
references/phases-7-12.mdmarkdown21.4 KB
scripts/find-failure-reason.jsexecutablescript4.8 KB
scripts/poll-status.jsexecutablescript3.5 KB
scripts/render-apex.jsexecutablescript2.0 KB
scripts/run-data-transform.jsexecutablescript4.2 KB
scripts/schedule-business-period-export.apexother1.7 KB
scripts/sf-rest.jsexecutablescript5.7 KB
scripts/soql-escape.jsexecutablescript755 B

scripts/find-failure-reason.js

View on GitHub
#!/usr/bin/env node
/**
 * Extracts the actual failure reason for a FailedStatus app-framework install
 * (e.g. the TPE Analytics App in Phase 11, or the C360 SDM app in Phase 6).
 *
 * `applicationStatus: FailedStatus` alone carries no detail — the underlying
 * per-requirement failure message only lives on the install's Domino runtime
 * (the App Framework's async execution graph), never on the app resource
 * itself. This script walks that graph so nothing in this skill has to
 * hand-parse it inline:
 *   1. GET /app-framework/apps/<appId>/activities -> latest activity's
 *      runtimeRequest.id (the runtime request tied to the failed install).
 *   2. GET /domino/runtimes/<runtimeRequestId> -> definition.nodes, each
 *      keyed by a graph node name (e.g. "template_requirement_<dmo>").
 *   3. Collect every node whose results.validate.taskStatus starts with
 *      "Fail" (covers FailEndOfPhaseStatus and any other Fail* variant) and
 *      its statusMessage — that message is the human-readable reason.
 *   4. Classify: a message matching the DMO-readiness template
 *      ("...[<dmo__dlm>] enabled or minimum required set of fields mapped
 *      in your org...") is a "DMO not available" failure; its DMO API name
 *      is pulled out of the message for the caller to act on (see this
 *      skill's Phase 11 debugging steps).
 *
 * Usage:
 *   node find-failure-reason.js --target-org <username> --app-id <appId>
 *
 * Prints one line of JSON: {"failedNodes":[{"node","statusMessage"}],
 * "dmoNotAvailable":["ssot__BusinessPeriod__dlm", ...]}. Exit 0 whether or
 * not a failure was found (this is a read-only diagnostic, not a
 * pass/fail gate) — exit 1 only on a request/usage error.
 */

const { restRequest } = require('./sf-rest');

function parseArgs(argv) {
  const args = {};
  for (let i = 0; i < argv.length; i += 1) {
    const token = argv[i];
    if (!token.startsWith('--')) continue;
    args[token.slice(2)] = argv[i + 1];
    i += 1;
  }
  return args;
}

function requireArg(args, name) {
  if (!args[name]) {
    console.error(`Missing required --${name}`);
    process.exit(1);
  }
  return args[name];
}

async function getJson(targetOrg, path) {
  const { ok, status, body } = await restRequest({ targetOrg, path, method: 'GET' });
  if (!ok) {
    throw new Error(`HTTP ${status} for ${path}: ${JSON.stringify(body)}`);
  }
  return body;
}

// The chain's own failMessage template is inconsistent about the opening
// "[" (confirmed live: BusinessPeriod's message has it, MeasureDefinition's
// doesn't) — match the closing "]" only and treat the opening one as
// optional. statusMessage also arrives HTML-entity-encoded (e.g. "&#39;"
// for an apostrophe); decode the handful of entities this template uses
// before matching or displaying it.
const DMO_NOT_AVAILABLE_PATTERN =
  /don't have \[?([\w.]+__dlm)\] enabled or minimum required set of fields mapped/;

function decodeEntities(text) {
  return text
    .replace(/&#39;/g, "'")
    .replace(/&quot;/g, '"')
    .replace(/&amp;/g, '&')
    .replace(/&lt;/g, '<')
    .replace(/&gt;/g, '>');
}

async function main() {
  const args = parseArgs(process.argv.slice(2));
  const targetOrg = requireArg(args, 'target-org');
  const appId = requireArg(args, 'app-id');

  let runtimeRequestId = args['runtime-request-id'];
  if (!runtimeRequestId) {
    const activities = await getJson(
      targetOrg,
      `/services/data/v67.0/app-framework/apps/${appId}/activities`
    );
    const items = activities.items || [];
    if (!items.length) {
      process.stdout.write(JSON.stringify({ failedNodes: [], dmoNotAvailable: [] }));
      return;
    }
    // Activities are returned most-recent-first; the latest install attempt
    // is the one whose reason we want.
    runtimeRequestId = items[0].runtimeRequest && items[0].runtimeRequest.id;
    if (!runtimeRequestId) {
      process.stdout.write(JSON.stringify({ failedNodes: [], dmoNotAvailable: [] }));
      return;
    }
  }

  const runtime = await getJson(
    targetOrg,
    `/services/data/v67.0/domino/runtimes/${runtimeRequestId}`
  );
  const nodes = (runtime.definition && runtime.definition.nodes) || {};

  const failedNodes = [];
  const dmoNotAvailable = [];

  for (const [nodeName, node] of Object.entries(nodes)) {
    const validate = node.results && node.results.validate;
    const taskStatus = validate && validate.taskStatus;
    if (!taskStatus || !taskStatus.startsWith('Fail')) continue;

    const statusMessage = decodeEntities(validate.statusMessage || '');
    failedNodes.push({ node: nodeName, statusMessage });

    const match = statusMessage.match(DMO_NOT_AVAILABLE_PATTERN);
    if (match) dmoNotAvailable.push(match[1]);
  }

  process.stdout.write(JSON.stringify({ failedNodes, dmoNotAvailable }));
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall