【问题标题】:cannot update lookup field when uploading document using CopyIntoItems使用 CopyIntoItems 上传文档时无法更新查找字段
【发布时间】:2009-12-16 15:02:09
【问题描述】:

我正在尝试使用 Copy.asmx 网络服务、CopyIntoItems 方法从本地计算机上传文档。我可以成功上传文档和 DateTime 属性,但无法更新文档库的查找属性。我正在使用带有 sp2 的 MOSS 2007

我使用的代码如下所示:

string[] destinationUrls = { Uri.EscapeUriString(destinationUrl) };

CopySharepointService.FieldInformation dateInformation = new CopySharepointService.FieldInformation();
dateInformation.DisplayName = "Date";
dateInformation.Type = CopySharepointService.FieldType.DateTime;
dateInformation.Value = DateTime.Today.ToString();

CopySharepointService.FieldInformation fundInformation = new CopySharepointService.FieldInformation();
fundInformation.DisplayName = "Fund";
fundInformation.Type = CopySharepointService.FieldType.Lookup;
fundInformation.Id = new Guid(fundGuidItem); // This is the GUID of the field being updated in the document library
fundInformation.Value = "1";

CopySharepointService.FieldInformation[] info = { dateInformation, fundInformation };            
CopySharepointService.CopyResult[] result;    
CopySharepointService.CopySoapClient CopyService2007 = new CopySoapClient("CopySoap");

CopyService2007.ClientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
CopyService2007.CopyIntoItems(destinationUrl, destinationUrls, info, fileData, out result);

文档已成功上传,但查阅字段未更新

有人可以帮忙吗?

【问题讨论】:

    标签: web-services sharepoint-2007


    【解决方案1】:

    我刚刚找到了这个帖子:

    “不幸的是,CopyIntoItems 不会将信息放入“File”、“Computed”或“Lookup”类型的字段中。Web 服务使用 SPCopy 类的 CopyIntoItem,它调用称为 FieldShouldBeCopiedTo 的私有方法。此方法包含防止查找字段被复制的逻辑。”

    http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/2fdc9933-ddb8-446f-80ad-6c8e17dfdb6f

    我有时讨厌 SharePoint。

    【讨论】:

      【解决方案2】:

      没办法,伙计们;唯一的选择是重新连接,获取列表项本身并以这种方式更新元数据。请记住:查找字段需要使用number;# 的格式 - 所以如果你是如果数据是:

      12;#Some Option
      

      在 Xml 批量更新中使用 12;#

      【讨论】:

        【解决方案3】:

        不幸的是,您必须通过UpdateListItems 调用来设置所有“有趣”的元数据。

        来自链接中的示例:

        Web_Reference_Folder.Lists listService = new Web_Reference_Folder.Lists();
        listService.Credentials= System.Net.CredentialCache.DefaultCredentials;
        
        string strBatch = "<Method ID='1' Cmd='Update'>" + 
            "<Field Name='ID'>4</Field>" +
            "<Field Name='Field_Number'>999</Field></Method>" +
            "<Method ID='2' Cmd='Update'><Field Name='ID' >6</Field>" +
            "<Field Name='Field_DateTime'>
                2003-11-11T09:15:30Z</Field></Method>"; 
        
        XmlDocument xmlDoc = new System.Xml.XmlDocument();
        
        System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch");
        
        elBatch.SetAttribute("OnError","Continue");
        elBatch.SetAttribute("ListVersion","1");
        elBatch.SetAttribute("ViewName",
            "0d7fcacd-1d7c-45bc-bcfc-6d7f7d2eeb40");
        
        elBatch.InnerXml = strBatch;
        
        XmlNode ndReturn = listService.UpdateListItems("List_Name", elBatch);
        
        MessageBox.Show(ndReturn.OuterXml);
        

        【讨论】:

        • 你有一个例子的链接吗?
        猜你喜欢
        • 1970-01-01
        • 2020-02-07
        • 2017-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-08-09
        • 2017-11-10
        相关资源
        最近更新 更多