SharePoint sp-pnp-js清除/清空多用户字段

时间:2017-08-05 06:32:25

标签: sharepoint sharepoint-online

查看此处提供的示例(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);
                    });

1 个答案:

答案 0 :(得分:0)

如果是用户字段值,则字段名称应引用为<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);
});