使用迁移API

时间:2018-04-03 14:20:24

标签: sharepoint sharepoint-online

我正在编写c#代码,使用迁移API将一组文件迁移到Sharepoint(o365),并且我已成功使用下面链接中提到的方法完成迁移。

http://case.schollaart.net/2016/03/10/office365-migration-using-c-sharp.html

但是我无法更新复杂字段类型,例如文档库中的查找字段和用户类型字段。

是否有针对此方案的任何建议或方法?

1 个答案:

答案 0 :(得分:0)

您可以使用SharePoint CSOM库更新查找和人员字段,请查看此演示,Project是查找字段,CurrentUser字段是设置为当前用户的人员字段:

    using (var ctx = new ClientContext(@"http://sp2016/sites/test"))
    {

        var list = ctx.Web.Lists.GetByTitle("myList");
        var item = list.GetItemById(4);

        item["Title"] = "test";
        var currentUser = ctx.Web.CurrentUser;
        ctx.Load(item);
        ctx.Load(currentUser, user => user.Id);
        ctx.ExecuteQuery();
        FieldUserValue uservalue = new FieldUserValue();
        uservalue.LookupId = currentUser.Id;
        item["CurrentUser"] = uservalue;
        FieldLookupValue lv = new FieldLookupValue();
        lv.LookupId = 1;
        item["Project"] = lv;
        item.Update();
        ctx.ExecuteQuery();
    }
相关问题