6

Should this CAML be working. (I tried it with u2u and it does not display the URL column.) I get this error. {System.ApplicationException} = {"One or more field types are not installed properly. Go to the list settings page to delete these fields."}

<Where>
 <Eq>
     <FieldRef Name='URL' />
     <Value Type='URL'>/path/HR Policy.docx</Value>
 </Eq>
</Where>
Mina Kumari
  • 85
  • 2
  • 2
  • 6

1 Answers1

6

Querying for a Document in a Document Library

Looks like you are trying to find a document in a document library using CAML. You can do this by using the hidden column named "FileRef":

<Where><Eq><FieldRef Name="FileRef"/><Value Type="Url">sites/SiteCollection/SubSite/Site Documents/Excel Report.xls</Value></Eq></Where>

Note: Do not include the server name or beginning /.

Querying for a document or list item with a URL field

The following examples assuming you have a list or library setup with a URL column named "My Document".

The link is to a document that is hosted on the sharepoint server (do not need server name):

<Where><Eq><FieldRef Name="My_x0020_Document"/><Value Type="URL">/sites/subsite/Site%20Documents/Excel%20Report.xls</Value></Eq></Where>

The link is an absolute URL to something not on the server... for example http://www.google.com:

<Where><Eq><FieldRef Name="My_x0020_Document"/><Value Type="URL">http://www.google.com</Value></Eq></Where>
Kit Menke
  • 7,046
  • 1
  • 32
  • 54
  • @Kit Menke: I tried this as well (including yours) but same field not installed error /sites/SiteCol/subsite/Shared Documents/March Excel Report.xls – Mina Kumari Mar 24 '11 at 12:28
  • @Mina Kumari: I've updated the answer to include a query for a document in a document library which I think is what you're after. – Kit Menke Mar 24 '11 at 18:07
  • 1
    @Kit Menke: I am not getting that error with this code. I should see one file but no record is returned with the query. sites/SiteCollection/SubSite/Site Documents/Excel Report.xls – Mina Kumari Mar 24 '11 at 19:51
  • @Mina Kumari: What's the path of your document and did you put that into the query? Can you show the exact query you are trying? – Kit Menke Mar 24 '11 at 20:06
  • sites/gatorade/Shared Documents 5/Sales Folder/Team_lists.txt I put this in u2u tool. havnt tried in the winform app. – Mina Kumari Mar 24 '11 at 20:18
  • Ah... are you using `oQuery.ViewAttributes = "Scope=\"Recursive\"";`? http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.viewattributes.aspx Since it is in a folder you'll need the recursive attribute. – Kit Menke Mar 24 '11 at 20:30
  • 1
    @Kit Menke, I do have the recursive in the winform code. I tried your modified in u2u and i didnt see an option for recursive in u2u. I will try the modified in winform and let you know. Thanks – Mina Kumari Mar 24 '11 at 20:46
  • @Kit Menke. It finally worked. Thanks for sticking with me and resolve this issue. THANKS A LOT...... MINA – Mina Kumari Mar 24 '11 at 21:01
  • Hey it doesnt work for me when I write - /Sites/ASCAteam/GlobalBrandPlan/MigrationSpec-Rev-3rd_031915.xlsx but it works for a file which is directly under documents - Documents/SharePointDeleteListItemExample.properties – Tina Agrawal Apr 29 '15 at 06:24