0x81020014未正确安装一个或多个字段类型。转到列表设置页面以删除这些字段

时间:2009-08-19 15:21:39

标签: c# sharepoint sharepoint-2007 caml

在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中调试我的代码时,我得到上面的错误。

创建和调用Batch的代码如下:

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中运行,这就是为什么我感到困惑。

3 个答案:

答案 0 :(得分:2)

使用List的技巧是使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以查看“Field = Name”。这是您在创建字段时需要使用的名称。

答案 1 :(得分:1)

我在代码中使用了错误的List而错误。

答案 2 :(得分:0)

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

如果你徘徊一会儿,你会发现列表GUID,查看GUID,并跟随所有列表列。在使用GetListItems检索列表项时,查看SPD特别有用,并且需要使用“ows_”+ ColumnName解析XML。