如何在共享点列表中添加多个查找值。在共享点中添加项目时

发布于 2024-12-13 19:58:31 字数 864 浏览 2 评论 0原文

我的任务有多个相关文档 ID,例如相关文档 =“3,5,2,6”,现在我需要将多个值添加到任务列表中称为相关文档的共享点查找字段。如何添加这个?

作为参考,请参阅下面我的代码

   private static void CreateItem(SPWeb web, SPList TaskList, string FolderURL, string ItemName, string RelatedDoc)
    {
        var ParentURL = string.Empty;
        if (!TaskList.ParentWebUrl.Equals("/"))
        {
            ParentURL = TaskList.ParentWebUrl;
        }
        SPListItem _taskList = TaskList.AddItem(ParentURL + FolderURL, SPFileSystemObjectType.File, null);
        _taskList["Title"] = ItemName;
        string DocName = "4,6,3,6";//Document ref id.
        SPFieldLookupValue lookupvalue = new SPFieldLookupValue();

        if (DocName != "")
            lookupvalue = new SPFieldLookupValue(RelatedDoc, DocName);
        _taskList["EYRelatedSharedDocument"] = lookupvalue;
        _taskList.Update();

    }

My Task have multiple relateddocId for example RelatedDoc="3,5,2,6", now i need to add multiplevalue to the sharepoint lookup fields called related Document which is in task list. how to add this?

For ref see my code below

   private static void CreateItem(SPWeb web, SPList TaskList, string FolderURL, string ItemName, string RelatedDoc)
    {
        var ParentURL = string.Empty;
        if (!TaskList.ParentWebUrl.Equals("/"))
        {
            ParentURL = TaskList.ParentWebUrl;
        }
        SPListItem _taskList = TaskList.AddItem(ParentURL + FolderURL, SPFileSystemObjectType.File, null);
        _taskList["Title"] = ItemName;
        string DocName = "4,6,3,6";//Document ref id.
        SPFieldLookupValue lookupvalue = new SPFieldLookupValue();

        if (DocName != "")
            lookupvalue = new SPFieldLookupValue(RelatedDoc, DocName);
        _taskList["EYRelatedSharedDocument"] = lookupvalue;
        _taskList.Update();

    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

开始看清了 2024-12-20 19:58:31
SPFieldLookupValueCollection documents = new SPFieldLookupValueCollection();

foreach ( ... )
{
    documents.Add(new SPFieldLookupValue(documentId, documentTitle));
}

_taskList["EYRelatedSharedDocument"] = documents;
_taskList.Update();
SPFieldLookupValueCollection documents = new SPFieldLookupValueCollection();

foreach ( ... )
{
    documents.Add(new SPFieldLookupValue(documentId, documentTitle));
}

_taskList["EYRelatedSharedDocument"] = documents;
_taskList.Update();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文