SharePoint sp-pnp-js clear/empty 多用户字段

SharePoint sp-pnp-js clear/empty multi user field

查看此处提供的示例 (https://github.com/SharePoint/PnP-JS-Core/wiki/Working-With:-Items)

我试图清除(更新)多用户字段,但它没有清除。我错过了什么?我尝试将其设置为 null 或空数组,但均因错误请求而失败。

                    pnp.sp.web
                    .lists.getByTitle('Agreements')
                    .items.getById(agreement.Id)
                    .update({
                        Notes: 'Notes go here..',
                        // Clear Multi User Approver Field.
                        CurrentApprover: { results: [] },
                    })
                    .then((result) => {
                        resolve({ result: true });
                    }).catch((e) => {
                        console.log(e);
                    });

在用户字段值的情况下,字段名称应引用为 <UserFieldName>Id。例如,对于名称为 CurrentApprover 的字段,该字段应引用为 CurrentApproverId。这可能就是为什么在您的案例中更新时用户字段值被忽略的原因。

更新示例

pnp.sp.web
.lists.getByTitle('Agreements')
.items.getById(agreement.Id)
.update({
    Notes: 'Notes go here..',
    // Clear Multi User Approver Field.
    CurrentApproverId: { results: [] },
})
.then((result) => {
   resolve({ result: true });
}).catch((e) => {
   console.log(e);
});