【问题标题】:SharePoint sp-pnp-js clear/empty multi user fieldSharePoint sp-pnp-js 清除/清空多用户字段
【发布时间】:2017-08-07 22:11:18
【问题描述】:

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

【问题讨论】:

    标签: sharepoint sharepoint-online


    【解决方案1】:

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

    【讨论】:

    • 您好,抱歉回复晚了。是的,非常感谢你,很好的收获!
    猜你喜欢
    • 2021-01-04
    • 2015-10-06
    • 2018-11-30
    • 1970-01-01
    • 1970-01-01
    • 2014-05-29
    • 2011-08-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多