Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am trying to check if a filename exists in the 'Name' column of Shared Docs Library. I think only CAML could help here. So I made this query

"<Where><Eq><FieldRef Name='Name' /><Value Type='Text'>" + docname + "</Value></Eq></Where>"

But I get this error One or more field types are not installed properly. Go to the list settings page to delete these fields.

 string docname = "Disabled Service";  
        StringBuilder sb = new StringBuilder();  
        sb.Append("<Where><Eq><FieldRef Name='Name' /><Value Type='Text'>"+docname+"</Value></Eq></Where>");  
        SPQuery spq = new SPQuery();  
        spq.Query = sb.ToString();  
        spq.RowLimit = 1;  
SPList list = web.Lists["Shared Documents"];  
                    DataTable dt = list.GetItems(spq).GetDataTable();  

Kindly help..

share|improve this question
    
got it with "FileLeafRef" Thanks –  sanju May 6 '12 at 17:26

1 Answer 1

The internal name of Name is FileLeafRef so your query should be:

"<Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='File'>" + docname + "</Value></Eq></Where>"

If you don't like building the query by hand then a couple of good tools are:
- U2U CAML Query Builder which gives you an UI for building the query.
- CAML.NET which is a library for safely building CAML queries

share|improve this answer
    
And there's also the Stramit CAML Viewer, spcamlviewer.codeplex.com –  PirateEric May 7 '12 at 12:44
    
I'd be curious to know how you find a list of the correct names for fields to use in CAML? Title is "Title" but Name is actually "FileLeafRef"? What gives? –  Ray Nov 22 '12 at 23:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.