add-sharepoint

Adds 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.

Provider: Microsoft Power Platform APIs Path in repo: plugins/code-apps/skills/add-sharepoint/SKILL.md

Skill body

πŸ“‹ Shared Instructions: shared-instructions.md - Cross-cutting concerns.

References:

Add SharePoint

Two paths: existing lists (skip to Step 6) or new lists (full workflow).

Workflow

  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

Step 1: Check Memory Bank

Check for memory-bank.md per shared-instructions.md.

Step 2: Plan

Ask the user:

  1. Which SharePoint list(s) do they need?
  2. Do the lists already exist on their site, or do they need to create new ones?

If lists already exist: Skip to Step 6.

If creating new lists:

Step 3: Setup Graph API Auth (if creating lists)

See api-authentication-reference.md for full details.

az account show   # Verify Azure CLI logged in

$api = Initialize-SharePointGraphApi -SiteUrl "https://<tenant>.sharepoint.com/sites/<site-name>"
$headers = $api.Headers
$siteId = $api.SiteId

Requires Sites.Manage.All permission.

Step 4: Review Existing Lists (if creating lists)

Always query existing lists first before creating:

$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

See list-management-reference.md for Find-SimilarLists, Compare-ListSchemas, and Get-ListSchema functions.

Present findings to user with AskUserQuestion:

Step 5: Create Lists (if creating lists)

Get explicit confirmation before creating. Use safe functions from list-management-reference.md:

Step 6: Get Connection ID

Find the SharePoint Online connection ID (see connector-reference.md):

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.

Step 7: Discover Sites

List available SharePoint sites the user has access to:

npx power-apps list-datasets -a sharepointonline -c <connection-id>

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.

If npx power-apps list-datasets fails or returns no results:

Step 8: Discover Tables

For each selected site, list the available lists and document libraries:

npx power-apps list-tables -a sharepointonline -c <connection-id> -d '<site-url>'

If npx power-apps list-tables fails or returns no results:

Present the tables to the user and ask which ones they want to add. Suggest tables that look relevant to their use case (based on memory bank context or the user’s stated requirements). If lists were created in Step 5, they should appear here.

Step 9: Add Connector

SharePoint is a tabular datasource – requires -c (connection ID), -d (site URL), and -t (list name):

npx power-apps add-data-source -a sharepointonline -c <connection-id> -d '<site-url>' -t '<table-name>'

Run the command for each list or library the user selected. The -d (dataset) is the SharePoint site URL from Step 7, -t (table) is the list/library name from Step 8.

Step 10: Configure

Read sharepoint-reference.md before writing any SharePoint code – column encoding, choice fields, and lookups have critical gotchas.

Common operations:

// Get items from a SharePoint list
const items = await SharePointOnlineService.GetItems({
  dataset: "https://contoso.sharepoint.com/sites/your-site",
  table: "Your List Name"
});

// Create a new list item
await SharePointOnlineService.PostItem({
  dataset: "https://contoso.sharepoint.com/sites/your-site",
  table: "Your List Name",
  item: {
    Title: "New Item",
    Description: "Item description",
    Status: "Active"
  }
});

// Get files from a document library
const files = await SharePointOnlineService.ListFolder({
  dataset: "https://contoso.sharepoint.com/sites/your-site",
  id: "Shared Documents" // Library name or folder ID
});

// Get file content
const content = await SharePointOnlineService.GetFileContent({
  dataset: "https://contoso.sharepoint.com/sites/your-site",
  id: "file-server-relative-url"
});

Key points:

Use Grep to find specific methods in src/generated/services/SharePointOnlineService.ts (generated files can be very large – see connector-reference.md).

Step 11: Build

npm run build

Fix TypeScript errors before proceeding. Do NOT deploy yet.

Step 12: Update Memory Bank

Update memory-bank.md with: connector added, site URL, lists/libraries configured (or created), build status.

Skill frontmatter

user-invocable: true allowed-tools: Read, Edit, Write, Grep, Glob, Bash, LSP, TaskCreate, TaskUpdate, TaskList, TaskGet, AskUserQuestion, Skill, EnterPlanMode, ExitPlanMode model: opus