flexcard-state-management

Use when designing FlexCard actions, conditional visibility, and state that must survive navigation, refresh, or parent/child card transitions. Triggers: 'flexcard state', 'flexcard conditional visibility', 'flexcard actions', 'flexcard refresh', 'child flexcard state'. NOT for raw LWC state or for OmniScript step state.

Best use case

flexcard-state-management is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use when designing FlexCard actions, conditional visibility, and state that must survive navigation, refresh, or parent/child card transitions. Triggers: 'flexcard state', 'flexcard conditional visibility', 'flexcard actions', 'flexcard refresh', 'child flexcard state'. NOT for raw LWC state or for OmniScript step state.

Teams using flexcard-state-management should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/flexcard-state-management/SKILL.md --create-dirs "https://raw.githubusercontent.com/PranavNagrecha/AwesomeSalesforceSkills/main/skills/omnistudio/flexcard-state-management/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/flexcard-state-management/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How flexcard-state-management Compares

Feature / Agentflexcard-state-managementStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use when designing FlexCard actions, conditional visibility, and state that must survive navigation, refresh, or parent/child card transitions. Triggers: 'flexcard state', 'flexcard conditional visibility', 'flexcard actions', 'flexcard refresh', 'child flexcard state'. NOT for raw LWC state or for OmniScript step state.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# FlexCard State Management

FlexCard state problems rarely look like state problems at first. They look like "the card didn't refresh," "the button did nothing," or "the child card shows stale data." The underlying cause is almost always that FlexCard state has multiple layers — data source state, element-level state, conditional visibility state, and pubsub state — and the author treated them as a single thing. Good FlexCard design names each layer explicitly and decides, per action, which layer must refresh and which must not.

FlexCard holds data in a local session cache keyed by the data source. Actions operate on that cache — they can refresh an element, refresh the whole card, or re-invoke the data source. Conditional visibility reads from the cache, not from Salesforce. That means a record update from elsewhere does not propagate until an action or pubsub tells the card to refresh.

Parent and child FlexCards share state only by contract: parent passes parameters down, child refreshes upward via events or pubsub. A child FlexCard cannot reach into the parent's cache. A parent cannot force a child to refresh except via a pubsub event the child has subscribed to.

---

## Before Starting

- List each FlexCard involved and their parent/child relationships.
- Identify actions bound to buttons, icons, or menu items, and their targets.
- Identify conditional visibility rules and the fields or session variables they read.
- Note whether any card is embedded inside an OmniScript or a Lightning page — both change refresh semantics.

## Core Concepts

### State Layers

1. **Data source state** — the response cached after the data source ran. Survives until the card reloads or a `Refresh Card Data` action fires.
2. **Element state** — per-element bindings (e.g. a node's visibility flag). Re-evaluated on element refresh.
3. **Conditional visibility state** — a derived read of the data source state. It does not poll.
4. **Pubsub state** — ephemeral, runtime-only. Lost on navigation.
5. **Session variables** — name-scoped variables within the runtime; useful for short-lived coordination between cards.

### Action Refresh Targets

- `Refresh Card Data` — re-runs the data source; use when data could have changed server-side.
- `Refresh Card State` — re-renders from cache; use when only derived state changed.
- `Refresh Element` — re-renders one node; use when one button/row needs to update.
- `Refresh Parent` / `Refresh Sibling` — cross-card; requires pubsub or `omnistudioFlexCard` framework events.

### Cross-Card Coordination

Parent-child coordination uses input parameters and events. Sibling-to-sibling coordination uses pubsub. Do not try to reach into another card's cache — that coupling breaks when either card is redesigned.

---

## Common Patterns

### Pattern 1: Optimistic UI With Post-Save Refresh

Run the action, immediately update element state to reflect the expected outcome, then trigger `Refresh Card Data` on success to reconcile with the server.

### Pattern 2: Pubsub For Sibling Refresh

When card A's action should refresh card B, publish a named event from A and subscribe in B. Both cards still own their own data source; neither depends on the other's internal cache shape.

### Pattern 3: Parameter-Driven Child Rerender

Pass the controlling record ID as an input parameter to the child card. When the parent's selection changes, update the input binding — the child refreshes automatically because its parameters changed.

### Pattern 4: Session-Variable Handoff

When a parent action should hand a value to a sibling or to a nested OmniScript step, write to a session variable. Read it in the consumer. Treat these like global scope — name them carefully.

### Pattern 5: Conditional Visibility Gated On Action Completion

For "show after save" UX, bind visibility to a derived field that the action writes into the cache on success. Avoid binding visibility to raw `isLoading`-style flags; they fight with normal data source refreshes.

---

## Decision Guidance

| Situation | Recommended Approach | Reason |
|---|---|---|
| Card shows stale value after record update | `Refresh Card Data`, not `Refresh Card State` | State refresh reads cache; data refresh re-queries |
| Child card needs to update when parent selection changes | Parameter-driven rerender | Cleanest coupling contract |
| Sibling card must refresh after a save | Pubsub event | No shared parent-owned state needed |
| Button should disable during action | Element-level state + action completion event | Avoid full-card refresh churn |
| Visibility depends on derived/computed state | Compute in data source or action, store in cache | Conditional visibility is not a function engine |

## Review Checklist

- [ ] Each action names its refresh target deliberately.
- [ ] Parent/child coupling uses input parameters, not reach-in reads.
- [ ] Sibling coupling uses pubsub, not shared globals.
- [ ] Conditional visibility reads fields that exist in the cache after the governing action completes.
- [ ] Session variables are namespaced and documented.
- [ ] Refresh Card Data is used only when the server state could have changed.

## Recommended Workflow

1. Inventory — list the cards, their data sources, and the actions on each.
2. Classify refresh intent — element, card state, card data, or cross-card for every action.
3. Choose coupling — parameters for parent-child, pubsub for sibling.
4. Implement and simulate — test with the FlexCard preview's action trace.
5. Validate — run this skill's checker against the card metadata.
6. Document — record the state flow diagram alongside the FlexCard definition.

---

## Salesforce-Specific Gotchas

1. `Refresh Card State` does not re-run the data source; stale data persists.
2. Pubsub events do not survive navigation between Lightning pages.
3. Session variables are shared across the page, not just the card — collisions are common.
4. Conditional visibility uses the cached response, not live field values.
5. Child FlexCards inside an OmniScript step reset when the user navigates between steps.

## Proactive Triggers

Surface these WITHOUT being asked:

- Action uses `Refresh Card State` after a `Record/Update` → Flag High. Likely wanted `Refresh Card Data`.
- Child card reads parent's session variable without subscribing → Flag Medium. Fragile coupling.
- Pubsub event published with generic name (e.g. `refresh`) → Flag Medium. Namespace collision risk.
- Conditional visibility bound to a field the action does not write → Flag High. Will never toggle.
- Card uses `Reload Card` on every action → Flag Medium. Performance regression.

## Output Artifacts

| Artifact | Description |
|---|---|
| State flow diagram | Parent/child/sibling map with refresh arrows |
| Action refresh matrix | Per-action target and justification |
| Pubsub event catalog | Event names, publishers, subscribers |

## Related Skills

- `omnistudio/flexcard-design-patterns` — layout and composition.
- `omnistudio/omnistudio-cache-strategies` — data source caching.
- `omnistudio/omnistudio-lwc-integration` — when LWC embeds FlexCard.
- `omnistudio/omnistudio-debugging` — tracing action and refresh flow.

Related Skills

session-management-and-timeout

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when configuring session timeout values, concurrent session limits, session IP locking, or logout behavior in Salesforce. Covers org-wide session settings, profile-level overrides, Connected App session policies, and Metadata API SecuritySettings deployment. NOT for OAuth token refresh flows, login IP ranges, or MFA/identity-provider configuration.

oauth-token-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when work depends on how Salesforce OAuth access and refresh tokens are issued, refreshed, rotated, revoked, or introspected for a Connected App or API client—including unexpected logouts, invalid_grant after refresh, or designing token incident response. NOT for choosing which OAuth grant or Connected App flow to implement (use integration/oauth-flows-and-connected-apps), Named Credential packaging (use integration/named-credentials-setup), or broad Connected App IP and PKCE policy hardening without a token-lifecycle angle (use security/connected-app-security-policies).

certificate-and-key-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when creating, uploading, or rotating certificates in Salesforce, configuring mutual TLS (mTLS) client authentication, managing the Java KeyStore for CA-signed certificates, diagnosing certificate expiry in JWT OAuth flows, or understanding which certificate types Salesforce supports and how to migrate them between orgs. NOT for Named Credential configuration (use named-credentials-setup skill), NOT for Shield Platform Encryption key management. Trigger keywords: Certificate and Key Management, self-signed certificate, CA-signed certificate, mutual TLS, mTLS, keystore, JKS, PKCS12, certificate rotation, certificate expiry, JWT certificate.

omniscript-session-state

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when an OmniScript must persist mid-flow state across refresh, navigation, multi-device resume, or abandonment recovery. Covers session objects, staging data, OmniScript tracking, and resume URLs. Does NOT cover OmniScript UI step layout (see omniscript-design) or general Flow pause/resume (see flow-transaction-finalizer-patterns).

flexcard-design-patterns

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing, building, or reviewing OmniStudio FlexCards — including data source selection, card states, actions, conditional visibility, flyout configuration, and child card iteration. Triggers: 'FlexCard', 'card template', 'flyout', 'card action', 'card state', 'data source', 'child card', 'conditional visibility'. NOT for OmniScript design, standalone LWC development, or Apex controller architecture outside the FlexCard context.

flexcard-container-composition

8
from PranavNagrecha/AwesomeSalesforceSkills

Design FlexCard composition: parent/child state flow, layout modes, actions, event wiring, and data source selection. Trigger keywords: flexcard, flex card composition, parent child flexcard, flexcard state, flexcard events, flexcard datasource. Does NOT cover: the first-time FlexCard Hello-World (trailhead), LWC-native alternatives, or Experience Cloud theming.

lwc-state-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Share state across LWCs using pub/sub, Lightning Message Service, @wire, and reactive stores. NOT for in-component reactivity.

lwc-reactive-state-patterns

8
from PranavNagrecha/AwesomeSalesforceSkills

How LWC reactivity actually works after Spring '20 (API v48+) — every class field is reactive on reassignment, but @track is still required for in-place mutation of plain object/array contents, and Date / Set / Map mutations are NEVER observed. Covers the renderedCallback infinite-loop trap, reactive-getter caching rules, and when @track is genuinely needed today. NOT for @wire reactive parameters (see lwc/wire-adapters), NOT for Lightning Data Service caching (see lwc/ldws-and-uirecordapi), NOT for cross-component reactive state (see lwc/message-channel-patterns and lwc/state-management-with-modules).

lwc-focus-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when building LWCs that need to manage focus explicitly — modal dialogs, wizard flows, dynamic inserts, list updates, error summaries, and focus after async work. Covers focus restoration, focus traps, programmatic focus across shadow DOM, and patterns for announcing changes to assistive tech. Does NOT cover general LWC a11y audit (see lwc-accessibility).

lwc-cross-tab-state-sync

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when an LWC needs to react to events that happen in another browser tab — record updates, login state, draft autosave, console-tab navigation. Triggers: 'sync data across tabs', 'BroadcastChannel LWC', 'storage event LWC', 'one tab updates the other', 'console workspace tab close detection'. NOT for state sync within the same Lightning page (use Lightning Message Service) or for server-pushed updates (use CometD or refreshApex).

revenue-lifecycle-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when implementing or troubleshooting Salesforce Revenue Lifecycle Management (RLM) — the native Revenue Cloud product covering order-to-cash lifecycle, Dynamic Revenue Orchestrator (DRO) fulfillment plan design, asset amendments, billing schedule creation via Connect API, and invoice management. Triggers on: Dynamic Revenue Orchestrator, RLM order decomposition, DRO fulfillment swimlanes, native Revenue Cloud billing schedule, asset lifecycle management Salesforce. NOT for CPQ quoting or pricing rules (use cpq-* skills), not for the legacy Salesforce Billing managed package with blng__* objects (different product entirely), not for standard Order objects without Revenue Cloud features.

loyalty-management-setup

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when setting up or extending Salesforce Loyalty Management — including program and currency creation, tier group design, qualifying vs. non-qualifying point currency separation, DPE batch job activation, partner loyalty configuration, and member portal setup on Experience Cloud. Triggers on: Loyalty Management setup, loyalty tier setup Salesforce, qualifying points vs redemption points, DPE batch job for loyalty, partner loyalty program Salesforce, loyalty member portal. NOT for Marketing Cloud engagement program design (separate product), not for B2B loyalty via Sales Cloud (standard opportunity, not loyalty program), not for general Experience Cloud site setup (use experience-cloud-setup skill).