$npx -y skills add microsoft/power-platform-skills --skill assign-offline-profileUse when the user needs to bind users or teams to a Mobile Offline Profile so they actually receive offline sync on their devices. Without this, the profile exists in Dataverse but no one's app uses it.
| 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) — `usermobileofflineprofilemembership` / `teammobileofflineprofilemembership` entity field map |
| 6 | - [dataverse-offline-api.md](${CLAUDE_SKILL_DIR}/../../shared/references/dataverse-offline-api.md) — Web API recipe (§12 — membership POSTs) |
| 7 | |
| 8 | # Assign Offline Profile |
| 9 | |
| 10 | Bind one or more users and/or teams to an existing Mobile Offline Profile. Without this step, the profile exists in Dataverse but is unbound — no one's app actually uses it for offline sync. |
| 11 | |
| 12 | Per the maker portal's UX (the "Assign profile to user" dialog under env settings), this is a separate operation from profile creation. Many users hit "I created the profile but offline still doesn't work" — the missing piece is membership. |
| 13 | |
| 14 | ## Workflow |
| 15 | |
| 16 | 1. Verify project + locate profile → 2. Pick users/teams → 3. Discover existing memberships → 4. Confirm diff (single gate) → 5. POST memberships → 6. Verify → 7. Summary |
| 17 | |
| 18 | --- |
| 19 | |
| 20 | ### Step 1 — Verify project + locate profile |
| 21 | |
| 22 | ```bash |
| 23 | test -f power.config.json |
| 24 | node "${CLAUDE_SKILL_DIR}/../../scripts/resolve-environment.js" "$(node -e \"console.log(require('./power.config.json').environmentId)\")" |
| 25 | ``` |
| 26 | |
| 27 | Profile ID resolution (in order): |
| 28 | |
| 29 | | Source | Used when | |
| 30 | |---|---| |
| 31 | | `$ARGUMENTS` contains `--profile-id <guid>` | Explicit override | |
| 32 | | `$ARGUMENTS` contains `--profile-name <name>` | Resolve via `GET /mobileofflineprofiles?$filter=name eq '<name>'&$select=mobileofflineprofileid` | |
| 33 | | `offline-profile.json` in cwd | Read top-level `profileId` field | |
| 34 | | Otherwise | `GET /mobileofflineprofiles` and present `AskUserQuestion` with the list (max 4 options) | |
| 35 | |
| 36 | STOP if no profile can be resolved. Print: `Run /setup-offline-profile first, or pass --profile-id`. |
| 37 | |
| 38 | > **`power.config.json` is intentionally NOT consulted here.** That file is owned by `npx power-apps init`. The profile ID lives in `offline-profile.json` only. |
| 39 | |
| 40 | ### Step 2 — Pick users/teams |
| 41 | |
| 42 | `$ARGUMENTS` parsing: |
| 43 | |
| 44 | | Flag | Effect | |
| 45 | |---|---| |
| 46 | | `--user <upn>` (repeatable) | Add specific user(s) by UPN (`user@domain.com`) | |
| 47 | | `--team <name>` (repeatable) | Add specific team(s) by name | |
| 48 | | `--me` | Add the current Dataverse user from `WhoAmI` / `systemusers(<UserId>)` — useful for solo dev demos | |
| 49 | | `--all-app-users` | Add every user with **System User** role in the current env (broad; intended for prod rollout — confirm at gate) | |
| 50 | | `--unassign-user <upn>` / `--unassign-team <name>` | Remove an existing membership rather than add | |
| 51 | |
| 52 | If no flags passed, present `AskUserQuestion`: |
| 53 | |
| 54 | > **Question**: "Who should receive this offline profile?" |
| 55 | > |
| 56 | > **Options** (max 4): |
| 57 | > - `Just me (the current user)` — equivalent to `--me` |
| 58 | > - `Pick specific users by UPN` — you reply with comma-separated emails in the next message |
| 59 | > - `Pick a team` — list env's teams and pick one |
| 60 | > - `All users with System User role` — equivalent to `--all-app-users`; broad scope, confirm at gate |
| 61 | |
| 62 | For pick-users flow: after the choice, print: |
| 63 | |
| 64 | > "Reply with comma-separated UPNs (e.g. `rm1@contoso.com, rm2@contoso.com`)" |
| 65 | |
| 66 | Then read the next user message and parse. |
| 67 | |
| 68 | ### Step 3 — Discover existing memberships |
| 69 | |
| 70 | For idempotency: |
| 71 | |
| 72 | ```bash |
| 73 | # Existing user memberships for this profile |
| 74 | node "${CLAUDE_SKILL_DIR}/../../scripts/dataverse-request.js" <envUrl> GET \ |
| 75 | "usermobileofflineprofilememberships?\$filter=_mobileofflineprofileid_value eq <profileId>&\$select=usermobileofflineprofilemembershipid,_systemuserid_value&\$expand=systemuserid_systemuser(\$select=domainname)" |
| 76 | |
| 77 | # Existing team memberships for this profile |
| 78 | node "${CLAUDE_SKILL_DIR}/../../scripts/dataverse-request.js" <envUrl> GET \ |
| 79 | "teammobileofflineprofilememberships?\$filter=_mobileofflineprofileid_value eq <profileId>&\$select=teammobileofflineprofilemembershipid,_teamid_value&\$expand=teamid_team(\$select=name)" |
| 80 | ``` |
| 81 | |
| 82 | Build the set of `already-bound` UPNs and team names. |
| 83 | |
| 84 | For each candidate user/team from Step 2, look up their `systemuserid` / `teamid` (skip if already in `already-bound`): |
| 85 | |
| 86 | ```bash |
| 87 | node "${CLAUDE_SKILL_DIR}/../../scripts/dataverse-request.js" <envUrl> GET \ |
| 88 | "systemusers?\$filter=domainname eq '<upn>'&\$select=systemuserid,fullname,domainname&\$top=1" |
| 89 | |
| 90 | node "${CLAUDE_SKILL_DIR}/../../scripts/dataverse-request.js" <envUrl> GET \ |
| 91 | "teams?\$filter=name eq '<team-name>' and teamtype eq 0&\$select=teamid,name&\$top=1" |
| 92 | ``` |
| 93 | |
| 94 | (`teamtype eq 0` excludes Access Teams and Owner Teams — only Manage Teams get profile assignments.) |
| 95 | |
| 96 | Construct three lists: |
| 97 | - `t |