omnistudio-flexcard-generate: OmniStudio FlexCard Creation and Validation
Expert OmniStudio engineer specializing in FlexCard UI components for Salesforce Industries. Generate production-ready FlexCard definitions that display at-a-glance information with declarative data binding, Integration Procedure data sources, conditional rendering, and proper SLDS (Salesforce Lightning Design System) styling. All FlexCards are validated against a 130-point scoring rubric across 7 categories.
Scope
- In scope: Creating and validating OmniStudio FlexCard definitions (
OmniUiCard); configuring Integration Procedure data sources; designing card layouts, states, and action buttons; scoring against the 130-point rubric; deployment and activation
- Out of scope: Building OmniScripts (use
omnistudio-omniscript-generate), creating Integration Procedures (use omnistudio-integration-procedure-generate), mapping full dependency trees (use omnistudio-dependencies-analyze), deploying metadata to org (use platform-metadata-deploy)
Core Responsibilities
- FlexCard Authoring: Design and build FlexCard definitions with proper layout, states, and field mappings
- Data Source Binding: Configure Integration Procedure data sources with correct field mapping and error handling
- Test Generation: Validate cards against multiple data states (populated, empty, error, multi-record)
- Documentation: Produce deployment-ready documentation with data source lineage and action mappings
Document Map
| Need |
Document |
Description |
| Best practices |
references/best-practices.md |
Layout patterns, SLDS, accessibility, performance |
| Data binding |
references/data-binding-guide.md |
IP sources, field mapping, conditional rendering |
CRITICAL: Orchestration Order
FlexCards sit at the presentation layer of the OmniStudio stack. Ensure upstream components exist before building a FlexCard that depends on them.
omnistudio-dependencies-analyze → omnistudio-datamapper-generate → omnistudio-integration-procedure-generate → omnistudio-omniscript-generate → omnistudio-flexcard-generate (you are here)
FlexCards consume data from Integration Procedures and can launch OmniScripts. Build the data layer first, then the presentation layer.
Key Insights
| Insight |
Detail |
| Configuration fields |
OmniUiCard uses DataSourceConfig for data source bindings and PropertySetConfig for card layout, states, and actions. There is NO Definition field on OmniUiCard in Core namespace. |
| Data source binding |
Data sources bind to Integration Procedures for live data; the IP must be active and deployed before the FlexCard can retrieve data |
| Child card embedding |
FlexCards can embed other FlexCards as child cards, enabling composite layouts with shared or independent data sources |
| OmniScript launching |
FlexCards can launch OmniScripts via action buttons, passing context data from the card's data source into the OmniScript's input |
| Designer virtual object |
The FlexCard Designer uses OmniFlexCardView as a virtual list object (/lightning/o/OmniFlexCardView/home), separate from the OmniUiCard sObject where card records are stored. Cards created via API may not appear in "Recently Viewed" until opened in the Designer. |
Workflow (5-Phase Pattern)
Phase 1: Requirements Gathering
Before building, clarify these with the stakeholder:
| Question |
Why It Matters |
| What is the card's purpose? |
Determines layout type and data density |
| Which data sources are needed? |
Identifies required Integration Procedures |
| What object context does it run in? |
Determines record-level vs. list-level display |
| What actions should the card expose? |
Drives button/link configuration and OmniScript integration |
| What layout best fits the use case? |
Single card, list, tabbed, or flyout |
| Are there conditional display rules? |
Fields or sections that appear/hide based on data values |
Phase 2: Design & Layout
Read references/best-practices.md for layout patterns, SLDS compliance, accessibility requirements, and performance guidance before designing.
Card Layout Options
| Layout Type |
Use Case |
Description |
| Single Card |
Record summary |
One card displaying fields from a single record |
| Card List |
Related records |
Repeating cards bound to an array data source |
| Tabbed Card |
Multi-context |
Multiple states displayed as tabs within one card |
| Flyout Card |
Detail on demand |
Expandable detail panel triggered from a summary card |
Data Source Configuration
Each FlexCard data source connects to an Integration Procedure (or other source type) and maps response fields to display elements.
FlexCard → Data Source (type: IntegrationProcedure)
→ IP Name + Input Mapping
→ Response Field Mapping → Card Elements
- Map IP response fields to card display elements using
{datasource.fieldName} merge syntax
- Configure input parameters to pass record context (e.g.,
{recordId}) to the IP
- Set data source order when multiple sources feed the same card
Action Button Design
| Action Type |
Purpose |
Configuration |
| Launch OmniScript |
Start a guided process |
OmniScript Type + SubType, pass context params |
| Navigate |
Go to record or URL |
Record ID or URL template with merge fields |
| Custom Action |
Platform event, LWC, etc. |
Custom action handler with payload mapping |
Conditional Visibility
- Show/hide fields based on data values using visibility conditions
- Show/hide entire card states based on data source results
- Display empty-state messaging when data source returns no records
Phase 3: Generation & Validation
Read references/data-binding-guide.md for merge field syntax, data source types, and multi-source coordination before generating.
Read references/scoring-rubric.md for the full point-by-point breakdown when running the 130-point validation.
- Generate the FlexCard definition JSON
- Validate all data source references resolve to active Integration Procedures
- Run the 130-point scoring rubric (see Scoring section below)
- Verify merge field syntax matches IP response structure
- Check accessibility attributes on all interactive elements
Phase 4: Deployment
- Ensure all upstream Integration Procedures are deployed and active
- Run a dry-run check: use the
platform-metadata-deploy skill with --dry-run before committing
- Deploy the FlexCard metadata (
OmniUiCard) — sf project deploy start is safe to re-run; it upserts existing records
- Activate the FlexCard in the target org
- Embed the FlexCard in the target Lightning page, OmniScript, or parent FlexCard
- If deploy fails: check error output for specific cause — common issues: upstream IP not deployed (
Cannot find OmniIntegrationProcedure), missing namespace prefix (Entity not found), or FlexCard still in Draft status (activate before retrieving)
Phase 5: Testing
Test each FlexCard against multiple data scenarios:
| Scenario |
What to Verify |
| Populated data |
All fields render correctly, merge fields resolve |
| Empty data |
Empty-state message displays, no broken merge fields |
| Error state |
Graceful handling when IP returns an error or times out |
| Multi-record |
Card list renders correct number of items, pagination works |
| Action buttons |
OmniScript launches with correct pre-populated data |
| Conditional fields |
Visibility rules toggle correctly based on data values |
| Mobile |
Card layout adapts to smaller viewport widths |
Generation Guardrails
Avoid these patterns when generating FlexCard definitions:
| Anti-Pattern |
Why It's Wrong |
Correct Approach |
| Referencing non-existent IP data sources |
Card fails to load data at runtime |
Verify IP exists and is active before binding |
| Hardcoded colors in styles |
Breaks SLDS theming and dark mode |
Use SLDS design tokens and CSS custom properties |
| Missing accessibility attributes |
Fails WCAG compliance |
Add aria-label, role, and keyboard handlers |
| Excessive nested child cards |
Performance degrades with deep nesting |
Limit to 2 levels of nesting; flatten where possible |
| Ignoring empty states |
Broken UI when data source returns no records |
Configure explicit empty-state messaging |
| Hardcoded record IDs |
Card breaks across environments |
Use merge fields and context-driven parameters |
Scoring Rubric (130 Points)
All FlexCards are validated against 7 categories. Thresholds: [PASS] 90+ (Deploy) | [VERIFY] 67-89 (Review) | [BLOCK] <67 (Block - fix required)
| Category |
Points |
Criteria |
| Design & Layout |
25 |
Appropriate layout type, logical field grouping, responsive design, consistent spacing, clear visual hierarchy |
| Data Binding |
20 |
Correct IP references, proper merge field syntax, input parameter mapping, multi-source coordination |
| Actions & Navigation |
20 |
Action buttons configured correctly, OmniScript launch params mapped, navigation targets valid, action labels descriptive |
| Styling |
20 |
SLDS tokens used (no hardcoded colors), consistent typography, proper use of card/tile patterns, dark mode compatible |
| Accessibility |
15 |
aria-label on interactive elements, keyboard navigable actions, sufficient color contrast, screen reader friendly field labels |
| Testing |
15 |
Verified with populated data, empty state, error state, multi-record scenario, and mobile viewport |
| Performance |
15 |
Data source calls minimized, child card nesting limited (max 2 levels), no redundant IP calls, lazy loading for non-visible states |
Read references/scoring-rubric.md for the full per-criterion breakdown of all 7 categories.
CLI Commands
Read scripts/flexcard-commands.sh for all FlexCard CLI commands (query, retrieve, deploy). Replace <org> with your org alias and <Name> with the FlexCard API name.
Data Source Binding
FlexCard Data Source Configuration
The DataSourceConfig field on OmniUiCard contains the data source bindings as JSON. The PropertySetConfig field contains the card layout, states, and field definitions.
IMPORTANT: There is NO Definition field on OmniUiCard in Core namespace. Use DataSourceConfig for data sources and PropertySetConfig for layout.
Read assets/omni-ui-card.json for the complete OmniUiCard record template including the DataSourceConfig JSON structure.
Data Source Types
| Type |
dataSource.type |
When to Use |
| Integration Procedure |
IntegrationProcedures (plural, capital P) |
Primary pattern; calls an IP for live data |
| SOQL |
SOQL |
Direct query (use sparingly; prefer IP for abstraction) |
| Apex Remote |
ApexRemote |
Custom Apex class invocation |
| REST |
REST |
External API call via Named Credential |
| Custom |
Custom |
Custom data provider (pass JSON body directly) |
Field Mapping from IP Response
Map IP response fields to card display elements using merge field syntax:
IP Response: FlexCard Merge Field:
───────────── ─────────────────────
{ "Name": "Acme Corp" } → {Name}
{ "Account": { → {Account.Name}
"Name": "Acme Corp"
}
}
{ "records": [ → {records[0].Name} (single)
{ "Name": "Acme" } or iterate with Card List layout
]
}
Input Parameter Mapping
Pass context from the hosting page into the IP data source:
| Context Variable |
Source |
Example |
{recordId} |
Current record page |
Pass to IP to query related data |
{userId} |
Running user |
Filter data by current user |
{param.customKey} |
URL parameter or parent card |
Pass from parent FlexCard or URL |
Cross-Skill Integration
| Skill |
Relationship to omnistudio-flexcard-generate |
| omnistudio-integration-procedure-generate |
Build the IP data sources that FlexCards consume |
| omnistudio-omniscript-generate |
Build the OmniScripts that FlexCard action buttons launch |
| omnistudio-datamapper-generate |
Build DataRaptors/DataMappers that IPs use under the hood |
| omnistudio-dependencies-analyze |
Analyze dependency chains across FlexCards, IPs, and OmniScripts |
| platform-metadata-deploy |
Deploy FlexCard metadata along with upstream dependencies |
| experience-lwc-generate |
Build custom LWC components embedded within FlexCards |
Gotchas
| Scenario |
Handling |
| Empty data |
Configure an explicit empty-state with a user-friendly message; do not show raw "No data" or blank card |
| Error states |
Display a meaningful error message when the IP data source fails; log the error for debugging |
| Mobile responsiveness |
Use single-column layout for mobile; avoid horizontal scrolling; test at 320px viewport width |
| Long text values |
Truncate with ellipsis and provide a flyout or tooltip for full text |
| Large record sets |
Use card list with pagination; limit initial load to 10-25 records |
| Null field values |
Use conditional visibility to hide fields with null values rather than showing empty labels |
| Mixed data freshness |
When multiple data sources have different refresh rates, display a "last updated" indicator |
FlexCard vs LWC Decision Guide
| Factor |
FlexCard |
LWC |
| Build method |
Declarative (drag-and-drop) |
Code (JS, HTML, CSS) |
| Data binding |
Integration Procedure merge fields |
Wire service, Apex, GraphQL |
| Best for |
At-a-glance information display |
Complex interactive UIs |
| Testing |
Manual + data state verification |
Jest unit tests + manual |
| Customization |
Limited to OmniStudio framework |
Full platform flexibility |
| Reuse |
Embed as child cards |
Import as child components |
| When to choose |
Standard card layouts with IP data |
Custom behavior, animations, complex state |
Dependencies
Required: Target org with OmniStudio (Industries Cloud) license, sf CLI authenticated
For Data Sources: Active Integration Procedures deployed to the target org
For Actions: Active OmniScripts deployed (if action buttons launch OmniScripts)
Scoring: Block deployment if score < 67
Idempotency: sf project deploy start upserts metadata — safe to re-run without creating duplicates. Query first to confirm current state: see scripts/flexcard-commands.sh.
Namespace handling: In managed-package orgs, the metadata type may be prefixed (e.g., omnistudio__OmniUiCard). Check sfdx-project.json for the namespace. See scripts/flexcard-commands.sh for the namespaced deploy command.
Creating FlexCards programmatically: Use REST API (sf api request rest --method POST --body @file.json). Required fields: Name, VersionNumber, OmniUiCardType (e.g., Child). Set DataSourceConfig (JSON string) for data source bindings and PropertySetConfig (JSON string) for card layout. The sf data create record --values flag cannot handle JSON in textarea fields. Activate by updating IsActive=true after creation.
Output Expectations
Deliverables produced by this skill:
- FlexCard JSON definition (
assets/omni-ui-card.json template) — OmniUiCard record ready for REST API creation or metadata deployment
- Data source binding block —
DataSourceConfig JSON mapping Integration Procedure inputs and response fields to card elements
- Card layout config —
PropertySetConfig JSON defining card states, field display, conditional visibility, and action buttons
- Validation report — 130-point score across 7 categories with deploy/review/block threshold result
- Deployment checklist — confirms upstream IPs are active, FlexCard is activated, and embedded in target Lightning page or parent FlexCard
External References
- OmniStudio FlexCards (Trailhead) — Official learning module for FlexCard fundamentals and guided setup
- OmniStudio Developer Guide — Technical reference for FlexCard metadata, data source configuration, and component properties
- Salesforce Industries Documentation — FlexCard configuration guide covering layout, states, and actions
Reference File Index
| File |
When to read |
assets/omni-ui-card.json |
Phase 3 — Generation: OmniUiCard record template including DataSourceConfig JSON structure |
references/best-practices.md |
Phase 2 — Layout patterns, SLDS compliance, accessibility requirements, and performance guidance |
references/data-binding-guide.md |
Phase 2-3 — Data source types, merge field syntax, input parameter mapping, and multi-source coordination |
references/scoring-rubric.md |
Phase 3 — Full per-criterion breakdown of all 7 scoring categories (130 points) |
scripts/flexcard-commands.sh |
Phase 4 — All CLI commands for querying, retrieving, and deploying FlexCard metadata |
Pre-Delivery Checklist
1---
2name: omnistudio-flexcard-generate
3description: "OmniStudio FlexCard creation and validation with 130-point scoring. Use when building at-a-glance UI cards, configuring data source bindings to Integration Procedures, or reviewing existing FlexCard definitions for accessibility and performance. TRIGGER when: user creates FlexCards, configures data sources, designs card layouts, or asks about OmniUiCard metadata. DO NOT TRIGGER when: building OmniScripts (use omnistudio-omniscript-generate), creating Integration Procedures (use omnistudio-integration-procedure-generate), or analyzing dependencies (use omnistudio-dependencies-analyze)."
4metadata:
5 cliTools:
6 - tool: ["sf"]
7 semver: ">=2.0.0"
8 relatedSkills:
9 - "experience-lwc-generate"
10 - "omnistudio-datamapper-generate"
11 - "omnistudio-dependencies-analyze"
12 - "omnistudio-integration-procedure-generate"
13 - "omnistudio-omniscript-generate"
14 - "platform-metadata-deploy"
15 version: "1.0"
16 domains: ["OmniStudio"]
17 minApiVersion: "60.0"
18---
19
20# omnistudio-flexcard-generate: OmniStudio FlexCard Creation and Validation
21
22Expert OmniStudio engineer specializing in FlexCard UI components for Salesforce Industries. Generate production-ready FlexCard definitions that display at-a-glance information with declarative data binding, Integration Procedure data sources, conditional rendering, and proper SLDS (Salesforce Lightning Design System) styling. All FlexCards are validated against a **130-point scoring rubric** across 7 categories.
23
24## Scope
25
26- **In scope**: Creating and validating OmniStudio FlexCard definitions (`OmniUiCard`); configuring Integration Procedure data sources; designing card layouts, states, and action buttons; scoring against the 130-point rubric; deployment and activation
27- **Out of scope**: Building OmniScripts (use `omnistudio-omniscript-generate`), creating Integration Procedures (use `omnistudio-integration-procedure-generate`), mapping full dependency trees (use `omnistudio-dependencies-analyze`), deploying metadata to org (use `platform-metadata-deploy`)
28
29---
30
31## Core Responsibilities
32
331. **FlexCard Authoring**: Design and build FlexCard definitions with proper layout, states, and field mappings
342. **Data Source Binding**: Configure Integration Procedure data sources with correct field mapping and error handling
353. **Test Generation**: Validate cards against multiple data states (populated, empty, error, multi-record)
364. **Documentation**: Produce deployment-ready documentation with data source lineage and action mappings
37
38## Document Map
39
40| Need | Document | Description |
41|------|----------|-------------|
42| **Best practices** | [references/best-practices.md](references/best-practices.md) | Layout patterns, SLDS, accessibility, performance |
43| **Data binding** | [references/data-binding-guide.md](references/data-binding-guide.md) | IP sources, field mapping, conditional rendering |
44
45---
46
47## CRITICAL: Orchestration Order
48
49FlexCards sit at the presentation layer of the OmniStudio stack. Ensure upstream components exist before building a FlexCard that depends on them.
50
51```text
52omnistudio-dependencies-analyze → omnistudio-datamapper-generate → omnistudio-integration-procedure-generate → omnistudio-omniscript-generate → omnistudio-flexcard-generate (you are here)
53```
54
55FlexCards consume data from Integration Procedures and can launch OmniScripts. Build the data layer first, then the presentation layer.
56
57---
58
59## Key Insights
60
61| Insight | Detail |
62|---------|--------|
63| **Configuration fields** | `OmniUiCard` uses `DataSourceConfig` for data source bindings and `PropertySetConfig` for card layout, states, and actions. There is NO `Definition` field on `OmniUiCard` in Core namespace. |
64| **Data source binding** | Data sources bind to Integration Procedures for live data; the IP must be active and deployed before the FlexCard can retrieve data |
65| **Child card embedding** | FlexCards can embed other FlexCards as child cards, enabling composite layouts with shared or independent data sources |
66| **OmniScript launching** | FlexCards can launch OmniScripts via action buttons, passing context data from the card's data source into the OmniScript's input |
67| **Designer virtual object** | The FlexCard Designer uses `OmniFlexCardView` as a virtual list object (`/lightning/o/OmniFlexCardView/home`), separate from the `OmniUiCard` sObject where card records are stored. Cards created via API may not appear in "Recently Viewed" until opened in the Designer. |
68
69---
70
71## Workflow (5-Phase Pattern)
72
73### Phase 1: Requirements Gathering
74
75Before building, clarify these with the stakeholder:
76
77| Question | Why It Matters |
78|----------|---------------|
79| What is the card's purpose? | Determines layout type and data density |
80| Which data sources are needed? | Identifies required Integration Procedures |
81| What object context does it run in? | Determines record-level vs. list-level display |
82| What actions should the card expose? | Drives button/link configuration and OmniScript integration |
83| What layout best fits the use case? | Single card, list, tabbed, or flyout |
84| Are there conditional display rules? | Fields or sections that appear/hide based on data values |
85
86### Phase 2: Design & Layout
87
88Read `references/best-practices.md` for layout patterns, SLDS compliance, accessibility requirements, and performance guidance before designing.
89
90#### Card Layout Options
91
92| Layout Type | Use Case | Description |
93|-------------|----------|-------------|
94| **Single Card** | Record summary | One card displaying fields from a single record |
95| **Card List** | Related records | Repeating cards bound to an array data source |
96| **Tabbed Card** | Multi-context | Multiple states displayed as tabs within one card |
97| **Flyout Card** | Detail on demand | Expandable detail panel triggered from a summary card |
98
99#### Data Source Configuration
100
101Each FlexCard data source connects to an Integration Procedure (or other source type) and maps response fields to display elements.
102
103```text
104FlexCard → Data Source (type: IntegrationProcedure)
105 → IP Name + Input Mapping
106 → Response Field Mapping → Card Elements
107```
108
109- Map IP response fields to card display elements using `{datasource.fieldName}` merge syntax
110- Configure input parameters to pass record context (e.g., `{recordId}`) to the IP
111- Set data source order when multiple sources feed the same card
112
113#### Action Button Design
114
115| Action Type | Purpose | Configuration |
116|-------------|---------|---------------|
117| **Launch OmniScript** | Start a guided process | OmniScript Type + SubType, pass context params |
118| **Navigate** | Go to record or URL | Record ID or URL template with merge fields |
119| **Custom Action** | Platform event, LWC, etc. | Custom action handler with payload mapping |
120
121#### Conditional Visibility
122
123- Show/hide fields based on data values using visibility conditions
124- Show/hide entire card states based on data source results
125- Display empty-state messaging when data source returns no records
126
127### Phase 3: Generation & Validation
128
129Read `references/data-binding-guide.md` for merge field syntax, data source types, and multi-source coordination before generating.
130Read `references/scoring-rubric.md` for the full point-by-point breakdown when running the 130-point validation.
131
1321. Generate the FlexCard definition JSON
1332. Validate all data source references resolve to active Integration Procedures
1343. Run the 130-point scoring rubric (see Scoring section below)
1354. Verify merge field syntax matches IP response structure
1365. Check accessibility attributes on all interactive elements
137
138### Phase 4: Deployment
139
1401. Ensure all upstream Integration Procedures are deployed and active
1412. Run a dry-run check: use the `platform-metadata-deploy` skill with `--dry-run` before committing
1423. Deploy the FlexCard metadata (`OmniUiCard`) — `sf project deploy start` is safe to re-run; it upserts existing records
1434. Activate the FlexCard in the target org
1445. Embed the FlexCard in the target Lightning page, OmniScript, or parent FlexCard
1456. **If deploy fails**: check error output for specific cause — common issues: upstream IP not deployed (`Cannot find OmniIntegrationProcedure`), missing namespace prefix (`Entity not found`), or FlexCard still in Draft status (activate before retrieving)
146
147### Phase 5: Testing
148
149Test each FlexCard against multiple data scenarios:
150
151| Scenario | What to Verify |
152|----------|---------------|
153| **Populated data** | All fields render correctly, merge fields resolve |
154| **Empty data** | Empty-state message displays, no broken merge fields |
155| **Error state** | Graceful handling when IP returns an error or times out |
156| **Multi-record** | Card list renders correct number of items, pagination works |
157| **Action buttons** | OmniScript launches with correct pre-populated data |
158| **Conditional fields** | Visibility rules toggle correctly based on data values |
159| **Mobile** | Card layout adapts to smaller viewport widths |
160
161---
162
163## Generation Guardrails
164
165Avoid these patterns when generating FlexCard definitions:
166
167| Anti-Pattern | Why It's Wrong | Correct Approach |
168|--------------|---------------|-----------------|
169| Referencing non-existent IP data sources | Card fails to load data at runtime | Verify IP exists and is active before binding |
170| Hardcoded colors in styles | Breaks SLDS theming and dark mode | Use SLDS design tokens and CSS custom properties |
171| Missing accessibility attributes | Fails WCAG compliance | Add `aria-label`, `role`, and keyboard handlers |
172| Excessive nested child cards | Performance degrades with deep nesting | Limit to 2 levels of nesting; flatten where possible |
173| Ignoring empty states | Broken UI when data source returns no records | Configure explicit empty-state messaging |
174| Hardcoded record IDs | Card breaks across environments | Use merge fields and context-driven parameters |
175
176---
177
178## Scoring Rubric (130 Points)
179
180All FlexCards are validated against 7 categories. **Thresholds**: [PASS] 90+ (Deploy) | [VERIFY] 67-89 (Review) | [BLOCK] <67 (Block - fix required)
181
182| Category | Points | Criteria |
183|----------|--------|----------|
184| **Design & Layout** | 25 | Appropriate layout type, logical field grouping, responsive design, consistent spacing, clear visual hierarchy |
185| **Data Binding** | 20 | Correct IP references, proper merge field syntax, input parameter mapping, multi-source coordination |
186| **Actions & Navigation** | 20 | Action buttons configured correctly, OmniScript launch params mapped, navigation targets valid, action labels descriptive |
187| **Styling** | 20 | SLDS tokens used (no hardcoded colors), consistent typography, proper use of card/tile patterns, dark mode compatible |
188| **Accessibility** | 15 | `aria-label` on interactive elements, keyboard navigable actions, sufficient color contrast, screen reader friendly field labels |
189| **Testing** | 15 | Verified with populated data, empty state, error state, multi-record scenario, and mobile viewport |
190| **Performance** | 15 | Data source calls minimized, child card nesting limited (max 2 levels), no redundant IP calls, lazy loading for non-visible states |
191
192Read `references/scoring-rubric.md` for the full per-criterion breakdown of all 7 categories.
193
194---
195
196## CLI Commands
197
198Read `scripts/flexcard-commands.sh` for all FlexCard CLI commands (query, retrieve, deploy). Replace `<org>` with your org alias and `<Name>` with the FlexCard API name.
199
200---
201
202## Data Source Binding
203
204### FlexCard Data Source Configuration
205
206The `DataSourceConfig` field on `OmniUiCard` contains the data source bindings as JSON. The `PropertySetConfig` field contains the card layout, states, and field definitions.
207
208> **IMPORTANT**: There is NO `Definition` field on `OmniUiCard` in Core namespace. Use `DataSourceConfig` for data sources and `PropertySetConfig` for layout.
209
210Read `assets/omni-ui-card.json` for the complete OmniUiCard record template including the `DataSourceConfig` JSON structure.
211
212### Data Source Types
213
214| Type | `dataSource.type` | When to Use |
215|------|-------------------|-------------|
216| **Integration Procedure** | `IntegrationProcedures` (plural, capital P) | Primary pattern; calls an IP for live data |
217| **SOQL** | `SOQL` | Direct query (use sparingly; prefer IP for abstraction) |
218| **Apex Remote** | `ApexRemote` | Custom Apex class invocation |
219| **REST** | `REST` | External API call via Named Credential |
220| **Custom** | `Custom` | Custom data provider (pass JSON body directly) |
221
222### Field Mapping from IP Response
223
224Map IP response fields to card display elements using merge field syntax:
225
226```text
227IP Response: FlexCard Merge Field:
228───────────── ─────────────────────
229{ "Name": "Acme Corp" } → {Name}
230{ "Account": { → {Account.Name}
231 "Name": "Acme Corp"
232 }
233}
234{ "records": [ → {records[0].Name} (single)
235 { "Name": "Acme" } or iterate with Card List layout
236 ]
237}
238```
239
240### Input Parameter Mapping
241
242Pass context from the hosting page into the IP data source:
243
244| Context Variable | Source | Example |
245|-----------------|--------|---------|
246| `{recordId}` | Current record page | Pass to IP to query related data |
247| `{userId}` | Running user | Filter data by current user |
248| `{param.customKey}` | URL parameter or parent card | Pass from parent FlexCard or URL |
249
250---
251
252## Cross-Skill Integration
253
254| Skill | Relationship to omnistudio-flexcard-generate |
255|-------|---------------------------|
256| **omnistudio-integration-procedure-generate** | Build the IP data sources that FlexCards consume |
257| **omnistudio-omniscript-generate** | Build the OmniScripts that FlexCard action buttons launch |
258| **omnistudio-datamapper-generate** | Build DataRaptors/DataMappers that IPs use under the hood |
259| **omnistudio-dependencies-analyze** | Analyze dependency chains across FlexCards, IPs, and OmniScripts |
260| **platform-metadata-deploy** | Deploy FlexCard metadata along with upstream dependencies |
261| **experience-lwc-generate** | Build custom LWC components embedded within FlexCards |
262
263---
264
265## Gotchas
266
267| Scenario | Handling |
268|----------|---------|
269| **Empty data** | Configure an explicit empty-state with a user-friendly message; do not show raw "No data" or blank card |
270| **Error states** | Display a meaningful error message when the IP data source fails; log the error for debugging |
271| **Mobile responsiveness** | Use single-column layout for mobile; avoid horizontal scrolling; test at 320px viewport width |
272| **Long text values** | Truncate with ellipsis and provide a flyout or tooltip for full text |
273| **Large record sets** | Use card list with pagination; limit initial load to 10-25 records |
274| **Null field values** | Use conditional visibility to hide fields with null values rather than showing empty labels |
275| **Mixed data freshness** | When multiple data sources have different refresh rates, display a "last updated" indicator |
276
277---
278
279## FlexCard vs LWC Decision Guide
280
281| Factor | FlexCard | LWC |
282|--------|----------|-----|
283| **Build method** | Declarative (drag-and-drop) | Code (JS, HTML, CSS) |
284| **Data binding** | Integration Procedure merge fields | Wire service, Apex, GraphQL |
285| **Best for** | At-a-glance information display | Complex interactive UIs |
286| **Testing** | Manual + data state verification | Jest unit tests + manual |
287| **Customization** | Limited to OmniStudio framework | Full platform flexibility |
288| **Reuse** | Embed as child cards | Import as child components |
289| **When to choose** | Standard card layouts with IP data | Custom behavior, animations, complex state |
290
291---
292
293## Dependencies
294
295**Required**: Target org with OmniStudio (Industries Cloud) license, `sf` CLI authenticated
296**For Data Sources**: Active Integration Procedures deployed to the target org
297**For Actions**: Active OmniScripts deployed (if action buttons launch OmniScripts)
298**Scoring**: Block deployment if score < 67
299
300**Idempotency**: `sf project deploy start` upserts metadata — safe to re-run without creating duplicates. Query first to confirm current state: see `scripts/flexcard-commands.sh`.
301
302**Namespace handling**: In managed-package orgs, the metadata type may be prefixed (e.g., `omnistudio__OmniUiCard`). Check `sfdx-project.json` for the namespace. See `scripts/flexcard-commands.sh` for the namespaced deploy command.
303
304**Creating FlexCards programmatically**: Use REST API (`sf api request rest --method POST --body @file.json`). Required fields: `Name`, `VersionNumber`, `OmniUiCardType` (e.g., `Child`). Set `DataSourceConfig` (JSON string) for data source bindings and `PropertySetConfig` (JSON string) for card layout. The `sf data create record --values` flag cannot handle JSON in textarea fields. Activate by updating `IsActive=true` after creation.
305
306---
307
308## Output Expectations
309
310Deliverables produced by this skill:
311
312- **FlexCard JSON definition** (`assets/omni-ui-card.json` template) — `OmniUiCard` record ready for REST API creation or metadata deployment
313- **Data source binding block** — `DataSourceConfig` JSON mapping Integration Procedure inputs and response fields to card elements
314- **Card layout config** — `PropertySetConfig` JSON defining card states, field display, conditional visibility, and action buttons
315- **Validation report** — 130-point score across 7 categories with deploy/review/block threshold result
316- **Deployment checklist** — confirms upstream IPs are active, FlexCard is activated, and embedded in target Lightning page or parent FlexCard
317
318---
319
320## External References
321
322- **OmniStudio FlexCards** (Trailhead) — Official learning module for FlexCard fundamentals and guided setup
323- **OmniStudio Developer Guide** — Technical reference for FlexCard metadata, data source configuration, and component properties
324- **Salesforce Industries Documentation** — FlexCard configuration guide covering layout, states, and actions
325
326---
327
328## Reference File Index
329
330| File | When to read |
331|------|-------------|
332| `assets/omni-ui-card.json` | Phase 3 — Generation: OmniUiCard record template including DataSourceConfig JSON structure |
333| `references/best-practices.md` | Phase 2 — Layout patterns, SLDS compliance, accessibility requirements, and performance guidance |
334| `references/data-binding-guide.md` | Phase 2-3 — Data source types, merge field syntax, input parameter mapping, and multi-source coordination |
335| `references/scoring-rubric.md` | Phase 3 — Full per-criterion breakdown of all 7 scoring categories (130 points) |
336| `scripts/flexcard-commands.sh` | Phase 4 — All CLI commands for querying, retrieving, and deploying FlexCard metadata |
337
338---
339
340## Pre-Delivery Checklist
341
342- [ ] Upstream Integration Procedures exist and are active before FlexCard depends on them
343- [ ] Orchestration order followed (FlexCard is last in the chain)