Add person resolver: email → LookupId for writing person columns
Person/group columns store a numeric LookupId into each site's hidden User Information List, and SPO's ensureUser needs certificate auth that client secrets can't provide — so resolve by querying the hidden list directly via Graph (item id IS the LookupId). New resolvePersonByEmail() in graph.mjs (server-side EMail/UserName filter with a paged case-insensitive scan fallback), a 'person' CLI command, and a sharepoint_resolve_person MCP tool (9 tools now). Verified live against known ground truth (LookupIds 53 and 136) plus the not-found path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -57,10 +57,18 @@ field name is usually `<DisplayInternalName>LookupId`. Getting the right id:
|
||||
- **Lookup**: the id is the target list item's `id`. Query the source list to
|
||||
find it.
|
||||
- **Person**: the id is the user's row id in the site's hidden *User Information
|
||||
List*. This is awkward to obtain via Graph alone; if you need to set people
|
||||
fields by email/name often, that's a good reason to add a resolver helper (or
|
||||
do it via the SharePoint REST `ensureUser` endpoint). Flag this to the user
|
||||
rather than guessing an id.
|
||||
List*. Resolve it by email with the built-in resolver — never guess:
|
||||
|
||||
```bash
|
||||
node scripts/sp.mjs person --site "<SITE_URL>" --email nashotay@pescoinc.biz
|
||||
# → { "lookupId": 53, "displayName": "Nashota Yazzie", "email": "..." }
|
||||
```
|
||||
|
||||
Then write `{"ProjectManagerLookupId": 53}`. Limitation: the hidden list only
|
||||
contains people who have accessed the site before. SharePoint's `ensureUser`
|
||||
(which force-adds someone) needs certificate-based app-only auth that client
|
||||
secrets can't provide — so if the resolver reports "not found", grant the
|
||||
person site access (or assign them once in the SharePoint UI), then retry.
|
||||
|
||||
If a write returns `400 invalidRequest` or `400 generalException`, the field
|
||||
name or one of these value formats is almost always the cause.
|
||||
|
||||
Reference in New Issue
Block a user