lwc-mobile-offline-and-briefcase

Use when designing LWCs that must work offline in the standard Salesforce Mobile App, and when configuring Briefcase Builder rules to prime records onto user devices. Covers form-factor detection (`@salesforce/client/formFactor`), Lightning Data Service offline-cache behavior, Briefcase priming-rule design, conflict resolution on reconnect, and the legacy SmartStore / IndexedDB picture for context. Triggers: 'briefcase builder rule design', 'lwc not working offline', 'how do I prime records to user devices', 'sync conflict on reconnect', 'offline draft persistence in lwc'. NOT for Field Service Mobile offline priming (use admin/fsl-mobile-app-setup or architect/fsl-offline-architecture — FSL has its own priming pipeline). NOT for general LWC mobile container patterns / device APIs (use lwc/lwc-offline-and-mobile).

Best use case

lwc-mobile-offline-and-briefcase is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use when designing LWCs that must work offline in the standard Salesforce Mobile App, and when configuring Briefcase Builder rules to prime records onto user devices. Covers form-factor detection (`@salesforce/client/formFactor`), Lightning Data Service offline-cache behavior, Briefcase priming-rule design, conflict resolution on reconnect, and the legacy SmartStore / IndexedDB picture for context. Triggers: 'briefcase builder rule design', 'lwc not working offline', 'how do I prime records to user devices', 'sync conflict on reconnect', 'offline draft persistence in lwc'. NOT for Field Service Mobile offline priming (use admin/fsl-mobile-app-setup or architect/fsl-offline-architecture — FSL has its own priming pipeline). NOT for general LWC mobile container patterns / device APIs (use lwc/lwc-offline-and-mobile).

Teams using lwc-mobile-offline-and-briefcase 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/lwc-mobile-offline-and-briefcase/SKILL.md --create-dirs "https://raw.githubusercontent.com/PranavNagrecha/AwesomeSalesforceSkills/main/skills/lwc/lwc-mobile-offline-and-briefcase/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/lwc-mobile-offline-and-briefcase/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How lwc-mobile-offline-and-briefcase Compares

Feature / Agentlwc-mobile-offline-and-briefcaseStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use when designing LWCs that must work offline in the standard Salesforce Mobile App, and when configuring Briefcase Builder rules to prime records onto user devices. Covers form-factor detection (`@salesforce/client/formFactor`), Lightning Data Service offline-cache behavior, Briefcase priming-rule design, conflict resolution on reconnect, and the legacy SmartStore / IndexedDB picture for context. Triggers: 'briefcase builder rule design', 'lwc not working offline', 'how do I prime records to user devices', 'sync conflict on reconnect', 'offline draft persistence in lwc'. NOT for Field Service Mobile offline priming (use admin/fsl-mobile-app-setup or architect/fsl-offline-architecture — FSL has its own priming pipeline). NOT for general LWC mobile container patterns / device APIs (use lwc/lwc-offline-and-mobile).

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

# LWC Mobile Offline and Briefcase

Activate this skill when an LWC must operate inside the standard Salesforce Mobile App with intermittent or no connectivity, and when a Briefcase Builder priming rule needs to be designed so that the records the LWC depends on are actually present on the device. The skill is about the *handshake* between Briefcase priming, LDS cache behavior, and offline-aware component code — not about general mobile UI patterns.

If the target is Field Service Mobile (the dispatcher/technician app), this is the wrong skill — FSL Mobile has its own offline priming pipeline that is configured separately and shares almost no implementation surface with Briefcase Builder. Use `admin/fsl-mobile-app-setup` instead.

---

## Before Starting

Gather this context before designing the priming rule or writing any LWC:

- **Which mobile app.** "Standard Salesforce Mobile App" (Lightning-based, available on App Store / Play Store, what most internal users see) is what Briefcase Builder targets. FSL Mobile, the Communities mobile experience, and the legacy Mobile Classic app are all different surfaces with different offline mechanisms.
- **Edition and license.** Briefcase Builder is generally available since Winter '21 and is included with Sales Cloud, Service Cloud, and most platform licenses. Verify under Setup → Briefcase Builder; if the node is missing, it's a licensing problem, not a config one.
- **Realistic offline duration.** A 30-minute commute is not the same problem as a full-shift field visit. Sub-hour use cases lean on LDS-only caching; multi-hour use cases require an explicit Briefcase rule. Above ~24 hours, conflict resolution becomes the dominant design problem, not data availability.
- **Record volume per user.** Briefcase has soft limits on records primed per user (Salesforce documents 400 records per object per user as a guideline, with a hard ceiling that varies by edition). A rule that primes "all open opportunities for the user" is fine for an AE with 20 active deals; the same rule is broken for a service rep with 5,000 open cases.
- **Read vs write.** A read-mostly offline UX (reps reviewing notes before a meeting) is straightforward; an offline-write UX (reps logging visit outcomes that will sync later) needs explicit conflict-resolution design and draft persistence.
- **Picklist / record type / profile dependencies.** Picklist value entries, record types, and dependent picklists are loaded lazily by LDS and are NOT primed by Briefcase Builder — they live in metadata and must be brought offline through a different mechanism (LDS metadata cache, which is opportunistic). This is the #1 source of "why is my offline form blank" tickets.

---

## Core Concepts

### Concept 1 — Three offline data layers, only one of which is configurable

When a user opens an LWC in the Salesforce Mobile App offline, data may come from any of three layers, in priority order:

1. **Briefcase-primed records.** Records explicitly listed in a Briefcase Builder rule for the user's assigned Briefcase. These are deterministic — if the rule says "all Accounts where Owner = current user," every matching Account is on the device after the last sync.
2. **LDS recently-viewed cache.** Records the user *opened* on the device in the last few hours. The Salesforce Mobile App caches the LDS payload for recently visited records and serves it offline as a courtesy. This is opportunistic and not configurable. Don't design an offline UX that depends on it.
3. **In-flight draft state.** Form-state held in component memory or `localStorage` by the LWC itself. Survives backgrounding but is lost if the app is force-quit unless you persist it explicitly.

Briefcase Builder is the only layer the admin/architect can directly control. The LDS cache is a backup; component-side draft persistence is the LWC author's responsibility.

The distinction matters because a typical "it works on my phone" demo shows recently-viewed-cache behavior — the demo user just opened the record, so it's cached. The same flow fails for a different user who hasn't visited that record. The fix is a Briefcase rule, not "test harder."

### Concept 2 — Briefcase Builder priming-rule shape

A Briefcase definition has three configuration surfaces:

- **Audience.** Which users get this Briefcase. Configured by Permission Set / Permission Set Group assignment. A user can belong to multiple Briefcases (the union of their primed records is what lands on the device).
- **Priming rule.** A SOQL-flavored filter on a root object — e.g., `Account WHERE OwnerId = $User.Id AND Account_Status__c = 'Active'`. The filter supports the standard SOQL operators and the special `$User.Id` token.
- **Related objects.** Optional child records to include for each primed root record. Defined as a parent → child traversal, e.g., from each Account include up to N Contacts and up to N open Opportunities. Each related object can have its own filter.

The thing that surprises most admins: only **certain object types are primable**. The supported list (per Salesforce docs) includes the common standard objects (Account, Contact, Opportunity, Case, Lead, Task, Event) and most custom objects, but excludes BigObjects, External Objects, ContentDocument blobs, AttachedContentDocument joins, and several setup/configuration object types. A rule referencing an unsupported object simply does nothing — the rule saves, the sync runs, no records appear, and there is no error message in Setup.

Limits to internalize:

- A user gets soft-limit guidance of ~400 records per object per Briefcase (consult Salesforce docs for the current published number — this has evolved).
- A user can have multiple Briefcases assigned simultaneously.
- The full Briefcase syncs at intervals controlled by the Mobile App; users do not get a "force sync now" button by default. The interval has tightened in recent releases but is not user-controllable.

### Concept 3 — LDS offline behavior vs. imperative Apex

Lightning Data Service (`@wire`, `lightning-record-form`, `lightning-record-edit-form`, `getRecord`, `getRecords`, `getRecordCreateDefaults`) is offline-aware. When the device is offline:

- `@wire(getRecord, ...)` returns the cached record if one exists, with the same shape as an online response. The component does not need any conditional offline branch — it just gets data.
- A user-initiated `lightning-record-edit-form` save while offline queues the change as a *pending action*. The Mobile App shows a queued-changes indicator. On reconnect, queued actions are submitted in order. This is the primary write path that "works offline" with no extra LWC code.
- `getRecord` for a record NOT in any cache layer returns an error, which the component must handle. Don't crash; show a "not available offline" empty state.

Imperative Apex (`@AuraEnabled` methods called from `import myMethod from '@salesforce/apex/Foo.bar'`) is **not offline-aware by default**. An imperative call while offline rejects with a network error. There is no automatic queuing, no automatic retry — the LWC author must catch the error and decide what to do (queue locally, show a friendly empty state, refuse the action).

Decision rule of thumb:

| If the LWC needs… | Use |
|---|---|
| Record CRUD on standard or custom sObjects | LDS (`lightning-record-form`, `getRecord`, `updateRecord`, `createRecord`) |
| A computed value or aggregation | Imperative Apex *with explicit offline handling* — pre-compute and cache the result on the record itself if the value matters offline |
| A custom picklist dependency map | LDS `getPicklistValues` — opportunistic offline only; design a fallback |
| External system data | Imperative Apex; assume offline = "not available" |

The rule simplifies: **lean on LDS for everything that LDS can model, and treat every imperative Apex call as online-only unless you've engineered otherwise.**

### Concept 4 — Conflict resolution on reconnect

When a user makes offline edits to a record that someone else (or another device of the same user) also edited, Salesforce Mobile applies a default last-write-wins reconciliation: the queued offline change overwrites the server value when the queued action runs.

Three problems this creates:

1. **Silent data loss for the *other* edit.** The dispatcher edited the case while the rep was in the field; rep's reconnect overwrites the dispatcher's change with no warning.
2. **Validation rule failure on sync.** Server-side validation rules fire at sync time, not at offline-edit time. A rep can fill in an offline form that violates a VR; the queued action fails on reconnect; the rep is now hours away with broken state and no recovery UI by default.
3. **Required-field added since the user went offline.** Admin adds a required field while the rep is offline; rep's queued change doesn't populate it; sync fails with a non-obvious error.

The Mobile App surfaces sync failures in a "Pending Changes" / "Sync Issues" UI, but it is opaque to the rep without coaching. For UX-critical offline write paths, the LWC should:

- Persist a draft separately from the LDS pending action (so the user can re-edit if sync fails).
- Display a "queued" indicator after a successful offline save.
- On reconnect, listen for sync errors via the standard Mobile App pending-action surface and offer a retry/edit path.

For high-stakes records (regulated industries, financial transactions, anything where silent overwrite is unacceptable), choose a *conflict-detection* pattern: before the offline edit form opens, capture `LastModifiedDate` on the record; on save, include that timestamp; if the queued action sees a later `LastModifiedDate` at sync time, route to a conflict-resolution screen instead of overwriting. This requires a custom Apex endpoint and explicit handling — it is the most expensive offline UX to build correctly.

---

## Recommended Workflow

1. **Confirm the scenario truly needs Briefcase.** If the offline window is < 1 hour and users will have already opened the records of interest, LDS recently-viewed cache is sufficient and a Briefcase rule is overhead. If the window is > 1 hour or users need data they haven't viewed yet, proceed.
2. **Audit LDS-vs-Imperative for your component.** Use the bundled `scripts/check_lwc_mobile_offline_and_briefcase.py` to walk your LWC bundles and flag imperative Apex calls — each is an offline failure point that needs explicit handling. Convert to LDS where possible; mark the rest with a "not available offline" affordance.
3. **Design the Briefcase priming rule on paper first.** Identify the root object, the filter (use `$User.Id` for owner-scoped rules), and the parent→child traversal. Estimate records-per-user under realistic conditions; if you exceed the published per-object soft limit, narrow the filter rather than splitting into multiple Briefcases.
4. **Verify object-type supportability.** Confirm every object in the rule appears in the Briefcase-supported list per Salesforce docs. ContentDocument blobs, BigObjects, and most setup objects are excluded. Substitute with a flat field on the parent object if the offline UX needs that data.
5. **Build the LWC with offline branches.** Wire LDS reads through `@wire(getRecord, ...)` rather than imperative methods. For writes, use `lightning-record-edit-form` (auto-queues on offline). For computed/aggregated values, pre-compute server-side and store on the record itself so LDS can serve them offline.
6. **Test with airplane mode, not "lost connection" simulation.** Open the Salesforce Mobile App, navigate to the LWC, enable airplane mode, exercise read and write paths, then disable airplane mode and verify the queued action lands. Repeat for force-quit-and-relaunch. Most "offline support" bugs surface at the second step, not the first.
7. **Document the conflict-resolution behavior for ops.** If your write path uses last-write-wins (the default), make sure the user-facing rollout doc says so. If you've built a conflict-detection branch, document the recovery UI and train on it.

---

## Review Checklist

- [ ] Briefcase priming rule has been designed and the audience permission set assigned to test users.
- [ ] Records-per-user estimate is below the published soft limit for every object in the rule.
- [ ] Every object referenced in the rule is on Salesforce's Briefcase-supported list.
- [ ] All imperative Apex calls in the LWC have an offline-error path (not just `.catch(noop)`).
- [ ] LDS reads (`@wire(getRecord)`) handle the "not in cache" error with an empty state.
- [ ] Forms used offline rely on `lightning-record-edit-form` or explicit `createRecord` / `updateRecord` queuing.
- [ ] Picklist values, record types, and dependent picklists have been verified to load offline (via LDS metadata cache or a fallback).
- [ ] Tested on a real device with airplane mode, including reconnect and sync-failure scenarios.
- [ ] Conflict-resolution UX (last-write-wins or detection) is documented for end users.

---

## Salesforce-Specific Gotchas

Surface-level highlights — see `references/gotchas.md` for the full list:

1. **Picklist values do not Briefcase-prime.** Custom picklists fall under metadata, not records, and rely on LDS metadata cache that is opportunistic.
2. **Record types are loaded lazily.** A user who hasn't opened a "create new Account" form recently may see no record-type options when offline, even though the Briefcase contains Account records.
3. **Long text and rich-text blobs may be truncated in cache.** Briefcase prioritizes structural fields; large blob fields can be skipped.
4. **`ContentDocument` files are not primed.** Files attached to records are pointers, not blobs, in offline cache. The file itself is not on the device.
5. **`@salesforce/client/formFactor` is `'Large'` even on tablets in landscape.** Don't use it as a proxy for "is mobile" — it's three values (`Large`, `Medium`, `Small`) and the breakpoints do not map to network state.

---

## Output Artifacts

| Artifact | Description |
|---|---|
| Briefcase priming rule design | Root object + filter + child traversal, with records-per-user estimate |
| Offline-aware LWC implementation | Component using LDS for cacheable paths and explicit error handling for imperative Apex |
| Conflict-resolution strategy | Last-write-wins (default) or detection-based (custom), with end-user UX documented |
| Airplane-mode test plan | Read/write/reconnect/force-quit scenarios with expected outcomes |

---

## Related Skills

- `lwc/lwc-offline-and-mobile` — broader LWC mobile container patterns, mobile-capability APIs, form-factor responsiveness; complement to this skill, not replacement
- `lwc/lwc-imperative-apex` — when offline analysis turns up unavoidable imperative calls, this skill covers the patterns
- `admin/fsl-mobile-app-setup` — for the Field Service Mobile equivalent (different priming pipeline entirely)
- `architect/fsl-offline-architecture` — architecture-level design for FSL offline use cases
- `apex/fsl-mobile-app-extensions` — custom-metadata and Apex patterns for FSL extensions

Related Skills

lwc-offline-and-mobile

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing or reviewing Lightning Web Components for the Salesforce mobile app, mobile device capabilities, or offline-aware behavior. Triggers: 'lightning/mobileCapabilities', 'mobile lwc', 'offline lwc', 'supported mobile app only', 'barcode scanner availability'. NOT for Mobile SDK or fully native app architecture unless the decision is whether LWC in the Salesforce mobile app is sufficient.

fsl-offline-architecture

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when designing FSL Mobile offline-first architecture: data priming strategy, priming limits, conflict resolution patterns, and sync failure handling. Trigger keywords: FSL offline priming, briefcase sync FSL, offline data limits, conflict resolution MERGE_ACCEPT_YOURS, ghost records FSL. NOT for LWC offline-and-mobile (generic LWC offline, covered by lwc/lwc-offline-and-mobile), standard Salesforce Mobile App offline, or Experience Cloud offline.

fsl-mobile-app-extensions

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when building custom LWC Quick Actions, Global Actions, deep links, or offline data extensions for the Salesforce Field Service (FSL) native mobile app. Trigger keywords: FSL mobile extension, LWC action FSL, field service deep link, offline custom action, FSL mobile toolkit. NOT for LWC in standard Salesforce mobile app or Lightning Experience.

fsl-custom-actions-mobile

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when building custom LWC actions for the FSL Mobile app: barcode scanning, GPS capture, photo/signature capture, or custom guided workflows on mobile. Trigger keywords: FSL Mobile custom action, lightning__GlobalAction FSL, barcode scanner LWC, mobileCapabilities, Nimbus plugin, FSL lightning SDK. NOT for standard Salesforce Mobile App quick actions, standard Experience Cloud pages, or desktop Lightning Experience LWC components.

mobile-publisher

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when planning, configuring, or maintaining a Salesforce Mobile Publisher branded app — a customer-facing or partner-facing mobile app distributed through Apple App Store or Google Play, built on either the Experience Cloud (LWR/Aura) Mobile Publisher template or the Field Service Mobile Publisher template. Triggers: 'salesforce mobile publisher branded app', 'experience cloud mobile app store distribution', 'mobile publisher push notifications certificate', 'app store review rejection salesforce', 'mobile publisher version policy update'. NOT for the standard Salesforce Mobile App customization (use lightning-app-builder-advanced), NOT for Field Service Lightning offline configuration (use fsl-mobile-app-setup), NOT for hybrid web apps embedded in WebView.

fsl-mobile-workflow-design

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when designing, troubleshooting, or reviewing FSL Mobile worker workflows — including job lifecycle management, offline data capture, customer signature collection, parts consumption, and geolocation-triggered status transitions. Trigger keywords: FSL mobile, field service mobile workflow, offline job lifecycle, technician mobile, service appointment status, briefcase priming, parts consumption mobile, signature capture FSL. NOT for mobile app installation/configuration, FSL scheduling optimization, Dispatcher Console setup, or Work Capacity management.

fsl-mobile-app-setup

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when configuring, extending, or troubleshooting the Salesforce Field Service (FSL) Mobile app for field technicians — including offline priming strategy, app extensions, deep linking, and custom branding. Trigger keywords: FSL mobile, Field Service mobile app, offline priming, mobile extension toolkit, app extensions for field service. NOT for standard Salesforce Mobile app configuration, Lightning App Builder layouts for desktop, or Field Service Lightning dispatcher console setup.

xss-and-injection-prevention

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when writing or reviewing Visualforce pages, Apex controllers, or LWC components that output user-supplied data, build dynamic queries, or construct HTTP responses. Triggers: 'XSS in Visualforce', 'SOQL injection vulnerability', 'how to encode output in Apex', 'JSENCODE Visualforce', 'open redirect prevention'. NOT for Apex CRUD/FLS enforcement (use soql-security or apex-crud-and-fls), NOT for Shield encryption (use shield-encryption-key-management), NOT for AppExchange security review process (use secure-coding-review-checklist).

visualforce-security-and-modernization

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when hardening or modernizing legacy Visualforce pages — covers the platform CSRF token model and when disabling it is a security regression, view state encryption guarantees and the 170 KB ceiling, FLS/CRUD enforcement gaps on `<apex:outputField>` and on getters that return sObjects, `<apex:includeScript>` interaction with the org Content Security Policy, hosting LWC inside a VF page via `lightning:container` / `lightning-out`, and the retire-vs-harden-vs-leave-alone decision for an inventory of legacy pages. Triggers: 'should I rewrite this Visualforce page in LWC', 'CSRF protection disabled on Visualforce page is that safe', 'community user sees a field they should not on a Visualforce page', 'view state encryption is that enough for sensitive data', 'how do I host an LWC inside a Visualforce page', 'apex:dynamicComponent and apex:actionFunction safe to keep'. NOT for greenfield Visualforce architecture (use apex/visualforce-fundamentals — controller types, view state pattern selection, PDF rendering); NOT for Visualforce email template authoring (use apex/visualforce-email-templates if/when that skill is authored); NOT for general Apex security review across triggers and async (use apex/soql-security and security/secure-coding-review-checklist).

transaction-security-policies

8
from PranavNagrecha/AwesomeSalesforceSkills

Transaction Security policy creation and configuration: condition builder, enhanced policies, enforcement actions (block, MFA, notification, end session), real-time monitoring mode, and policy troubleshooting. NOT for Event Monitoring log analysis or Shield Event Monitoring setup (use event-monitoring). NOT for Apex testing or debug-log analysis.

sso-saml-troubleshooting

8
from PranavNagrecha/AwesomeSalesforceSkills

Diagnosing broken SAML SSO into Salesforce — IdP-initiated vs SP-initiated flows, signing-certificate validity / expiry, NameID format mismatches, RelayState handling, audience / entityId / issuer mismatches, clock skew, the SAML Assertion Validator in Setup, the Login History debug log, and the My Domain prerequisite for SSO. Covers the standard diagnostic loop: read the SAML response, identify which check failed, fix at the IdP or SP. NOT for OAuth / OpenID Connect SSO (see security/oauth-openid-troubleshooting), NOT for setting up SSO from scratch (see security/sso-saml-setup).

shield-kms-byok-setup

8
from PranavNagrecha/AwesomeSalesforceSkills

Configure Shield Platform Encryption with customer-supplied (BYOK) or customer-held (Cache-Only Key Service) tenant secrets, rotate them, and recover. NOT for Classic Encryption or field masking.