$npx -y skills add microsoft/power-platform-skills --skill enable-tables-offlineUse when the user needs to enable the per-table prerequisites (Can be taken offline, Track changes) before a Dataverse table can be added to a Mobile Offline Profile. Pre-flight pass for /setup-offline-profile.
| 1 | **Shared instructions: [shared-instructions.md](${CLAUDE_SKILL_DIR}/../../shared/shared-instructions.md)** — read first. |
| 2 | |
| 3 | **References:** |
| 4 | |
| 5 | - [offline-profile-schema.md](${CLAUDE_SKILL_DIR}/../../shared/references/offline-profile-schema.md) — entity field map (`IsAvailableOffline`, `ChangeTrackingEnabled`) |
| 6 | |
| 7 | # Enable Tables Offline |
| 8 | |
| 9 | Flip `IsAvailableOffline=true` AND `ChangeTrackingEnabled=true` on the `EntityMetadata` of one or more Dataverse tables, then publish customizations. This is the prerequisite shown in Image 4 of the maker portal ("Can be taken offline" + "Track changes") — without both, a table CANNOT be added to a Mobile Offline Profile. |
| 10 | |
| 11 | Sequential (Dataverse metadata lock) and idempotent: re-running on an already-enabled table is a no-op. |
| 12 | |
| 13 | ## Workflow |
| 14 | |
| 15 | 1. Verify project & auth → 2. Resolve table list → 3. Inspect current state → Gate → 4. PUT EntityMetadata per table → 5. Publish → 6. Verify → 7. Summary |
| 16 | |
| 17 | --- |
| 18 | |
| 19 | ### Step 1 — Verify project & auth |
| 20 | |
| 21 | ```bash |
| 22 | test -f power.config.json && test -f app.config.js |
| 23 | node "${CLAUDE_SKILL_DIR}/../../scripts/resolve-environment.js" "$(node -e \"console.log(require('./power.config.json').environmentId)\")" |
| 24 | ``` |
| 25 | |
| 26 | Capture the **Environment URL** from the resolver for `<envUrl>`. STOP if not authenticated. |
| 27 | |
| 28 | ### Step 2 — Resolve table list |
| 29 | |
| 30 | Tables to enable come from one of (in order): |
| 31 | |
| 32 | | Source | Used when | |
| 33 | |---|---| |
| 34 | | `$ARGUMENTS` | User passed a comma- or space-separated list of logical names (e.g. `/enable-tables-offline cr123_note,cr123_visit`) | |
| 35 | | `.datamodel-manifest.json` | Default — read `tables[].logicalName` for every Dataverse-backed table in the app | |
| 36 | | `AskUserQuestion` | Only if both above are absent. Show the table list from `src/generated/services/*Service.ts` filenames and let the user pick. | |
| 37 | |
| 38 | If the resolved list is empty, STOP with: "No Dataverse tables found in this project. Run `/add-dataverse` first." |
| 39 | |
| 40 | ### Step 3 — Inspect current state |
| 41 | |
| 42 | **Print before starting:** |
| 43 | > "→ Querying current IsAvailableOffline + ChangeTrackingEnabled for <N> table(s)…" |
| 44 | |
| 45 | For each table, in sequence: |
| 46 | |
| 47 | ```bash |
| 48 | node "${CLAUDE_SKILL_DIR}/../../scripts/dataverse-request.js" <envUrl> GET \ |
| 49 | "EntityDefinitions(LogicalName='<table>')?\$select=LogicalName,DisplayName,IsAvailableOffline,ChangeTrackingEnabled,IsCustomizable" |
| 50 | ``` |
| 51 | |
| 52 | Build a status table: |
| 53 | |
| 54 | ```text |
| 55 | | Table | IsAvailableOffline | ChangeTrackingEnabled | IsCustomizable | Needs change? | |
| 56 | |--------------------|--------------------|-----------------------|----------------|---------------| |
| 57 | | cr123_note | false | false | true | YES (both) | |
| 58 | | cr123_visit | true | false | true | YES (track) | |
| 59 | | contact | true | true | true | NO | |
| 60 | ``` |
| 61 | |
| 62 | **Hard rule:** if `IsCustomizable.Value=false` on any table, that table CANNOT be modified. Drop it from the change set and flag in `DONE_WITH_CONCERNS` — system-managed tables (most OOB) require an admin solution patch path the skill does not handle. |
| 63 | |
| 64 | ### Gate — Approval before mutation |
| 65 | |
| 66 | Enter plan mode with the status table from Step 3 plus the planned operation per table. Wait for user `ExitPlanMode` before proceeding. |
| 67 | |
| 68 | Plan body: |
| 69 | |
| 70 | ```text |
| 71 | The following EntityMetadata changes will be PUT in sequence: |
| 72 | |
| 73 | cr123_note → set IsAvailableOffline=true, ChangeTrackingEnabled=true |
| 74 | cr123_visit → set ChangeTrackingEnabled=true (IsAvailableOffline already true) |
| 75 | |
| 76 | After all updates, a single PublishAllXml request will commit the changes. |
| 77 | |
| 78 | Tables already in the desired state are skipped (no API call). |
| 79 | ``` |
| 80 | |
| 81 | If the user rejects, STOP. If they approve, proceed. |
| 82 | |
| 83 | ### Step 4 — PUT EntityMetadata per table |
| 84 | |
| 85 | **Print before starting:** |
| 86 | > "→ Updating EntityMetadata for <N> table(s) sequentially (Dataverse serializes metadata writes)…" |
| 87 | |
| 88 | > **⚠️ Concurrency rule — do not violate.** Metadata writes hold an exclusive lock per org. Issue one PUT, wait for 2xx, then the next. No batching, no parallel calls. Same rule as `/add-dataverse` Step 5. |
| 89 | |
| 90 | For each table needing change (skip ones already in target state): |
| 91 | |
| 92 | ```bash |
| 93 | node "${CLAUDE_SKILL_DIR}/../../scripts/update-entity-offline-flags.js" <envUrl> \ |
| 94 | --table <table> \ |
| 95 | --offline true \ |
| 96 | --tracking true |
| 97 | ``` |
| 98 | |
| 99 | The helper: |
| 100 | - Re-reads `EntityMetadata` to pick up the current `MetadataId` + `SchemaName` (both required in the PUT body — Dataverse rejects PUT without them). |
| 101 | - Sends `MSCRM.MergeLabels: true` so display labels are preserved (the alternative wipes labels — never use `false`). |
| 102 | - Returns `{ "status": 2 |