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

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

                
         up vote8down votefavorite
4
CamlQuery query = new CamlQuery();
                    query.ViewXml = @"<View>"
                        + "<Query>"
                        + "<Where><Eq><FieldRef Name='Name' /><Value Type='Text'>"
                        + fileName
                        + "</Value>"
                        + "</Eq>"
                        + "</Where>"
                        + "</Query>"
                        + "</View>";
                    ListItemCollection item = list.GetItems(query);
                    clientContext.Load(item);
                    clientContext.ExecuteQuery();

This query gave me the error One or more field types are not installed properly. Go to the list settings page to delete these fields.

If I use <Where><Eq><FieldRef Name='Title' /><Value Type='Text'> instead of Name , it's OK.

What's wrong with it ?  Name is there in the list.

Thanks in advance !!!

share|improve this question
 
                                                                                                                    
in SPQuery you have to use Internal Names of fields. Please verify that field called what's the internal name of your Name field.                     – Marek Kembrowski                 Dec 11 '12 at 9:11                                                                            
                                                                                                                    
@MarekKembrowski - > What's internal Names ? Sorry I'm quite new to SharePoint.                     – kevin                 Dec 11 '12 at 9:13                                                                            
12                                                                                  
Long story short - SharePoint fields have two kinds of names - Display Name and Internal Name. In some places (like SPListItem[string fieldName]) Display Names have to be used, in some (like SPQuery) Internal Names have to be used. Easiest way to check, what's the Internal Name of your field, is to go to field definition on SharePoint site and check Query string in url. For example: http://localhost/_layouts/FldEdit.aspx?List={F8645DD3-CE80-4‌​ECF-849F-6F851EECA2A‌​7}&Field=LocalNumber my Local Number field has internal name LocalNumber.                     – Marek Kembrowski                 Dec 11 '12 at 9:18                                                                            
                                                                                                                    
So when we are uploading, we have to provide the internal name too? Or is it automatically created by SharePoint ? Thanks for your answer !!                     – kevin                 Dec 11 '12 at 10:16                                                                            
1                                                                                  
What do you mean by 'Uploding'? When you're creating new field (column) most of the time SharePoint is creating Internal Names automatically. In some scenarios, you can force to use Internal Name of your choose (when your creating field from xml), but most of the time, you don't have control over it.                     – Marek Kembrowski                 Dec 11 '12 at 10:22                                                                            
                

                                6 Answers                                 6                        

         up vote13down vote

If you rename a column that was defined, the internal name DOES NOT get updated. For instance, you create a custom list, it has the column 'Title' by default. If you change that column to, say, 'userId', the internal name for that column is still 'Title'.

share|improve this answer
 
   
                
         up vote3down vote

Not sure that this will fix that error message but this is how you can use Name:

Name (for an Out of the box document library) internal name is "BaseName".

You can use powershell to find internal names of all the columns on a list:

$web = Get-SPWeb http://yoursiteurl
$web.lists["The List Name"].Fields | FL Title, InternalName

example Query:

$query.set_innerXML("<Where><Eq><FieldRef Name='BaseName'></FieldRef><Value Type='Text'>" + $ItemName + "</Value></Eq></Where>")

Full example in powershell:

function Update-SPItem($proxy, $ItemName, $listName, $lastModified, $firstName, $lastName, $chID, $emplNumber, )
{          
   $doc = New-Object System.Xml.XmlDocument
   $viewFields = $doc.CreateElement("ViewFields")
   $viewFields.set_innerXML("<FieldRef Name='ID'></FieldRef>")
   $queryOptions = $doc.CreateElement("QueryOptions")
   $queryOptions.set_innerXML("<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns><DateInUtc>FALSE</DateInUtc><ViewAttributes Scope='RecursiveAll'/>")
   $query = $doc.CreateElement("Query")
   $query.set_innerXML("<Where><Eq><FieldRef Name='BaseName'></FieldRef><Value Type='Text'>" + $ItemName + "</Value></Eq></Where>")
   $results = $proxy.GetListItems($listName, "", $query, $viewFields, "", $queryOptions, "")
   $rowXml = $results.GetElementsByTagName("z:row")
   $ItemID = $rowXml.Item(0).GetAttribute("ows_ID")

   # Update the item
   $batch = $doc.CreateElement("Batch")
   $batch.SetAttribute("OnError", "Continue")
   $batch.SetAttribute("ListVersion","1")
   $batch.SetAttribute("ViewName", "")
   $batch.InnerXml = "<Method ID='1' Cmd='Update'><Field Name='ID'>" + $ItemID + 
                     "</Field><Field Name='ImageCreateDate'>" + $lastModified + 
                     "</Field><Field Name='FirstName'>" + $firstName + 
                     "</Field><Field Name='LastName'>" + $lastName + 
                     "</Field><Field Name='CardHolderID'>" + $chID + 
                     "</Field><Field Name='EmployeeNumber'>" + $emplNumber + 
                     "</Field></Method>"

   $result = $proxy.UpdateListItems($listName, $batch)
}
share|improve this answer
 
   
         up vote1down vote

I assume the problem that you have is not the <FieldRef Name='Name' />  but the <Value Type='Text'>. If you check the type of Name Field you will find it is a File. If anyone knows how to query that I would also be thankfull. For now I am using Title.

share|improve this answer
 
                                                                                                                    
We have to use Internal Name. Then we will be OK. For Name, it's <FieldRef Name='FileLeafRef' />. Good luck !!!                     – kevin                 Jun 13 '13 at 2:12                                                                                                     
         up vote1down vote

The same error message is displayed for a badly constructed queries such as ones that do not have topmost  tags around sibling elements.

They query:

<Where><Contains><FieldRef Name='...' /><Value Type='Text'>Foobar</Value></Contains></Where><OrderBy><FieldRef Name='Modified' /></OrderBy>

would give this same error message, but not:

<View><Where><Contains><FieldRef Name='...' /><Value Type='Text'>Foobar</Value></Contains></Where><OrderBy><FieldRef Name='Modified' /></OrderBy></View>
share|improve this answer
 
   
         up vote1down vote

If you create a field through the SharePoint 2010 List Settings page, any spaces in the field name will become sequences of _x0020_ for the field's internal name. Besides spaces, SharePoint will encode other non-standard characters in a similar manner. So, you'll see the name you want on the List's web page, but programmatic access will require the internal name constructed by SharePoint (they ought to allow us to specify the internal name...)

The comment from @MarekKembrowski to the Op tells how to get the internal name using your browser.

share|improve this answer
 
   
         up vote1down vote

I struggled with this for too long, and the answer was right in front of me. For me, the comment that  Marek Kembrowski posted to the original question, was exactly what I needed to do, but I glazed over it because it was a comment, so I'm going to reiterate what Marek said in my own words so that hopefully the next person that comes along with this issue won't miss the comment posted above.

In sharepoint, when you create a column, there are two text fields where you give information to describe the field, Column Name and Description.

enter image description here

What KILLED me, was that the sharepoint site was set up with the Column name [OrderID] and a different description [CON].

Here you can see what Sharepoint looks like with the OrderID created first and the OrderID I created after I figured out the problem . . . The difference is one of the OrderID column names says OrderID ;)

enter image description here

The ONLY way I can see the original column name, is to Hover over the column in the Library Settings as Marek mentioned above . . . this will show the link at the bottom of the browser.  If you click to edit it . . . it's not even right . . . doesn't even show anything about the real column name . . .even shows the description name in the column name field . . . GGRRRRRRR!!!!!

Anyhow, Here is the code I used to retrieve the data:

        // Starting with ClientContext, the constructor requires a URL to the 
        // server running SharePoint. 
        ClientContext context = new ClientContext(siteUrl);

        // The SharePoint web at the URL.
        Web web = context.Web;

        List docList = context.Web.Lists.GetByTitle("OrderDocuments");

        CamlQuery query2 = new CamlQuery();

        //This query will NOT work . . .CON is not a column in the sharepoint repository
        //query2.ViewXml = "<View><Query><Where><Eq><FieldRef Name='CON' /><Value Type='Number'>4</Value></Eq></Where></Query></View>";

        //This query WILL WORK.  The actual Column name is OrderID in Sharepoint
        query2.ViewXml = "<View><Query><Where><Eq><FieldRef Name='OrderID' /><Value Type='Number'>4</Value></Eq></Where></Query></View>";
        ListItemCollection collListItem = docList.GetItems(query2);

        context.Load(collListItem);
        context.ExecuteQuery();

+1 to Marek for the correct solution above.  I wish I'd seen it the first time I found this page. 

share|improve this answer
 
   
                        

 

posted @ 2017-09-08 10:16  sky20080101  阅读(314)  评论(0)    收藏  举报