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

when I debug i can see URL is valid (like below). Shared Documents is tie a to custom content type.

string fileURL = "Shared Documents/Marketing Folder/Sales_Report.txt";
oQuery.Query = @"<Where>
                  <BeginsWith>
                   <FieldRef Name='URL' />
                   <Value Type='Text'>" + fileURL + @"</Value> 
                  </BeginsWith> 
                 </Where>";
oQuery.ViewAttributes = "Scope=\"Recursive\"";

I tried , , all variation but NO SUCCESS. I am so feedup. I wish Microsoft would provide a validation tool for these types.

The url does not show up in the drop when i use u2u.

The following code gives me all the items in the Shared Documents.

            oQuery.Query = @"<Contains>
                              <Eq>
                                 <FieldRef Name='URL' />
                                 <Value Type='URL'>" + fileURL + @"</Value> 
                                </Eq> 
                           </Contains>";
share|improve this question
    
You definitely have a column called URL, yeah? A malformed CAML query will return all items. –  James Love Mar 23 '11 at 18:53
    
@James: Are you certain that I have to create a column "URL" and populated it "Relative URL". hmm, as I understood from somewhere it's already there by default (where you it's visible or not with sp gui or u2u caml builder or sp manager). I went to SQL db for the content db and i see that tp_DirName is populated with Relative URL. select * from alluserdata where tp_leafname='Sales_Report.txt' –  user2556 Mar 24 '11 at 14:04

1 Answer 1

up vote 0 down vote accepted

I found the answer on this forum. The u2u caml builder is not sophiscated enough to turn on the recursive mode. So the code worked when I put it in the console app (with query ViewAttributes recursive mode).

sites/SiteCollection/SubSite/Site Documents/Excel Report.xls

http://stackoverflow.com/questions/5300860/caml-get-an-item-by-its-url/5411001#5411001

share|improve this answer

Your Answer

 
discard

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