首页 > 解决方案 > 使用 pnp sp 时如何从 Principal Id 中找出名称?

问题描述

我需要找出我从 REST 调用返回的 principalId 编号的用户名或名称,该调用获取当前在 SharePoint 列表项上的角色分配。

我了解这可能涉及:

const r = await sp.web.lists.getByTitle('MyList').items.getById(theItem).roleAssignments() 

我发现没有解释如何执行此操作的文档。

标签: restspfxpnp-js

解决方案


再次回答了我自己的问题:

const assignments = await sp.web.lists.getByTitle('MyList').items.getById(theItem).roleAssignments();

const expanded = assignments[0].PrincipalId;

console.log(expanded, 'expanded');

推荐阅读