$npx -y skills add microsoft/power-platform-skills --skill add-sharepointAdds SharePoint Online connector to a Power Apps code app. Use when reading lists, managing documents, or integrating with SharePoint sites. Can also create new SharePoint lists.
| 1 | **📋 Shared Instructions: [shared-instructions.md](${PLUGIN_ROOT}/shared/shared-instructions.md)** - Cross-cutting concerns. |
| 2 | |
| 3 | **References:** |
| 4 | |
| 5 | - [sharepoint-reference.md](./references/sharepoint-reference.md) - Column encoding, choice fields, lookups, API patterns (CRITICAL) |
| 6 | - [api-authentication-reference.md](./references/api-authentication-reference.md) - Graph API auth, token, site ID |
| 7 | - [list-management-reference.md](./references/list-management-reference.md) - Query, create, extend lists and columns |
| 8 | |
| 9 | # Add SharePoint |
| 10 | |
| 11 | Two paths: **existing lists** (skip to Step 6) or **new lists** (full workflow). |
| 12 | |
| 13 | ## Workflow |
| 14 | |
| 15 | 1. Check Memory Bank → 2. Plan → 3. Setup Graph API Auth → 4. Review Existing Lists → 5. Create Lists → 6. Get Connection ID → 7. Discover Sites → 8. Discover Tables → 9. Add Connector → 10. Configure → 11. Build → 12. Update Memory Bank |
| 16 | |
| 17 | --- |
| 18 | |
| 19 | ### Step 1: Check Memory Bank |
| 20 | |
| 21 | Check for `memory-bank.md` per [shared-instructions.md](${PLUGIN_ROOT}/shared/shared-instructions.md). |
| 22 | |
| 23 | ### Step 2: Plan |
| 24 | |
| 25 | Ask the user: |
| 26 | |
| 27 | 1. Which SharePoint list(s) do they need? |
| 28 | 2. Do the lists **already exist** on their site, or do they need to **create new** ones? |
| 29 | |
| 30 | **If lists already exist:** Skip to Step 6. |
| 31 | |
| 32 | **If creating new lists:** |
| 33 | |
| 34 | - Ask about the data they need and design an appropriate schema |
| 35 | - Reuse existing lists when possible (don't duplicate) |
| 36 | - Enter plan mode with `EnterPlanMode`, present the list designs with columns and types |
| 37 | - Get approval with `ExitPlanMode` |
| 38 | |
| 39 | ### Step 3: Setup Graph API Auth (if creating lists) |
| 40 | |
| 41 | See [api-authentication-reference.md](./references/api-authentication-reference.md) for full details. |
| 42 | |
| 43 | ```powershell |
| 44 | az account show # Verify Azure CLI logged in |
| 45 | |
| 46 | $api = Initialize-SharePointGraphApi -SiteUrl "https://<tenant>.sharepoint.com/sites/<site-name>" |
| 47 | $headers = $api.Headers |
| 48 | $siteId = $api.SiteId |
| 49 | ``` |
| 50 | |
| 51 | Requires **Sites.Manage.All** permission. |
| 52 | |
| 53 | ### Step 4: Review Existing Lists (if creating lists) |
| 54 | |
| 55 | **Always query existing lists first before creating:** |
| 56 | |
| 57 | ```powershell |
| 58 | $existingLists = Invoke-RestMethod -Uri "https://graph.microsoft.com/v1.0/sites/$siteId/lists?`$select=id,displayName,description,list&`$filter=list/hidden eq false" -Headers $headers |
| 59 | ``` |
| 60 | |
| 61 | See [list-management-reference.md](./references/list-management-reference.md) for `Find-SimilarLists`, `Compare-ListSchemas`, and `Get-ListSchema` functions. |
| 62 | |
| 63 | Present findings to user with `AskUserQuestion`: |
| 64 | |
| 65 | - Lists that can be **reused** (already exist with matching columns) |
| 66 | - Lists that need **extension** (exist but missing columns) |
| 67 | - Lists that must be **created** (no match found) |
| 68 | |
| 69 | ### Step 5: Create Lists (if creating lists) |
| 70 | |
| 71 | Get explicit confirmation before creating. Use safe functions from [list-management-reference.md](./references/list-management-reference.md): |
| 72 | |
| 73 | - `New-SharePointListIfNotExists` |
| 74 | - `Add-SharePointColumnIfNotExists` |
| 75 | - `Add-SharePointLookupColumn` (for cross-list references) |
| 76 | |
| 77 | ### Step 6: Get Connection ID |
| 78 | |
| 79 | Find the SharePoint Online connection ID (see [connector-reference.md](${PLUGIN_ROOT}/shared/connector-reference.md)): |
| 80 | |
| 81 | Run the `/list-connections` skill. Find the SharePoint Online connection in the output. If none exists, direct the user to create one using the environment-specific Connections URL — construct it from the active environment ID in context (from `power.config.json` or a prior step): `https://make.powerapps.com/environments/<environment-id>/connections` → **+ New connection** → search for the connector → Create. |
| 82 | |
| 83 | ### Step 7: Discover Sites |
| 84 | |
| 85 | List available SharePoint sites the user has access to: |
| 86 | |
| 87 | ```bash |
| 88 | npx power-apps list-datasets -a sharepointonline -c <connection-id> |
| 89 | ``` |
| 90 | |
| 91 | Present the sites to the user and ask which one(s) they want to connect to. If the user already specified a site URL, confirm it appears in the list. |
| 92 | |
| 93 | **If `npx power-apps list-datasets` fails or returns no results:** |
| 94 | - Auth error: Run `npx power-apps logout`, then retry — the CLI will re-prompt browser login. |
| 95 | - Empty list: Confirm the connection ID is for a SharePoint Online connection and the user has access to at least one site. STOP if the list is empty after confirming. |
| 96 | - Any other non-zero exit: Report the exact error output. STOP. |
| 97 | |
| 98 | ### Step 8: Discover Tables |
| 99 | |
| 100 | For each selected site, list the available lists and document libraries: |
| 101 | |
| 102 | ```bash |
| 103 | npx power-apps list-tables -a sharepointonline -c <connection-id> -d '<site-url>' |
| 104 | ``` |
| 105 | |
| 106 | **If `npx power-apps list-tables` fails or returns no results:** |
| 107 | - Confirm the site URL from Step 7 is exact (copy from the output — do not retype). |
| 108 | - If still empty, the user may not have access to that |