2

在 sharepoint 中尝试更新列表时出现错误:

0x81020014One or more field types are not installed properly. Go to the list settings page to delete these fields.

正在创建的 Caml 是:

<Batch PreCalc='TRUE' OnError='Continue'>
    <Method ID='1' Cmd='Update'>
        <Field Name='ID'>4</Field>
        <Field Name='Flagged'>False</Field>
     </Method>
</Batch>

当我从 U2U 运行 Caml 时,它工作正常并且字段更新。当我在 VS 中调试代码时,出现上述错误。

创建和调用批处理的代码如下:

var ws = new com.freud.intranet.lists.Lists {
  Url = WebServiceHelper.wsContactsList,
  Credentials = WebServiceHelper.AdminCredentials
};
var batch = "<Batch PreCalc='TRUE' OnError='Continue'><Method ID='1' cmd='Update'><Field Name='ID'>" + contactID
            + "</Field><Field Name='Flagged'>" + flag + "</Field></Method></Batch>";
var document = new XmlDocument();
var stringReader = new StringReader(batch);
var xmlReader = XmlReader.Create(stringReader);
var node = document.ReadNode(xmlReader);
ws.UpdateListItems("Master Contact Joining Table", node);

为什么caml可以在U2U而不是VS中工作?

从谷歌搜索问题可能是因为我没有使用内部名称,但它确实在 U2U 中运行,这就是我感到困惑的原因。

4

3 回答 3

2

使用列表的技巧是正确获取 Web 服务位置,将引用的 Web 服务中的 URL 设置为正确的位置,并使用列表中定义的字段名称。

    private void ReadTaskandAddtask()
    {
        try
        {
            tcfifsharepoint.Lists listServiceBase = new tcfifsharepoint.Lists();

            // SharePoint Web Serices require authentication
            listServiceBase.Credentials = System.Net.CredentialCache.DefaultCredentials;
            listServiceBase.Url = "http://SPServer/Site/_vti_Bin/lists.asmx";

            String newIssueTitle = "Programmatically added issue 3";

            String listGUID = "FC519894-509A-4B66-861E-2813DDE14F46";
            String activeItemViewGUID = "C93FFC02-368B-4D06-A8AE-3A3BA52F4F0C";
             listGUID = "{FC519894-509A-4B66-861E-2813DDE14F46}";
             activeItemViewGUID = "{DCF35B63-F85C-463B-B1A1-716B4CF705C5}";

            // first check if item is already in the list
            XmlNode activeItemData = listServiceBase.GetListItems(listGUID, activeItemViewGUID, null, null, "", null, "");
            if (!activeItemData.InnerXml.Contains(newIssueTitle))
            {
                //*********************This is Working *********************************
                StringBuilder sb_method = new StringBuilder();
                sb_method.Append("<Method ID=\"1\" Cmd=\"New\">");
                sb_method.Append("<Field Name=\"Title\">Some Title 14</Field>");
                sb_method.Append("<Field Name=\"AssignedTo\">Name to assign</Field>");
                sb_method.Append("<Field Name=\"Status\">In Progress</Field>");
                sb_method.Append("<Field Name=\"Priority\">(3) Low</Field>");
                sb_method.Append("<Field Name=\"DueDate\">");
                sb_method.Append(DateTime.Parse(DateTime.Now.ToString()).ToString("yyyy-MM-ddTHH:mm:ssZ"));

                sb_method.Append("</Field>");
                sb_method.Append("<Field Name=\"PercentComplete\">.34</Field>");
                sb_method.Append("<Field Name=\"Body\">Something entered into the description field.</Field>");
                sb_method.Append("<Field Name=\"Author\">Your Author</Field>");
                sb_method.Append("<Field Name=\"Editor\">This is Modified By</Field>");
                sb_method.Append("</Method>");

                XmlDocument x_doc = new XmlDocument();

                XmlElement xe_batch = x_doc.CreateElement("Batch");
                xe_batch.SetAttribute("OnError", "Return");
                xe_batch.InnerXml = sb_method.ToString();

                XmlNode xn_return = listServiceBase.UpdateListItems("Task List Name", xe_batch);
        }
        catch (Exception e)
        {
            string sMessage = e.Message;

        }
    }

您可以通过选择“设置”下拉菜单并选择“列表设置”项来查看 SharePoint 列表中用于列表项(列)的内部名称。在列表设置中单击一列,然后查看 URL 以查看“字段 = 名称”。这是您在创建字段时需要使用的名称。

于 2009-09-16T19:53:24.723 回答
1

我在代码中使用了错误的列表,因此出现了错误。

于 2009-08-19T15:48:56.113 回答
0

此外,您可以尝试打开 SharePoint Designer 并查看任何给定的列表表单或视图。

如果您四处寻找,您会发现列表 GUID、视图 GUID 以及所有列表列。在使用 GetListItems 检索列表项并且您需要使用“ows_”+ ColumnName 解析 XML 时,查看 SPD 特别有用。

于 2010-01-07T20:49:08.913 回答