• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1858
  • Last Modified:

CAML and document library URL

Hello. Is it possible to use CAML to get url of document in library?  I would like to create a web part that shows hyperlinks to items in library. I played with CamlDesigner but I were not able get url to list item:


Open in new window

I could do something like that:

string url = basicurl+FileLeafRef (seem to be a file name with extensions). 

Open in new window

But still I am little bit confused, as I am able to get url to the list item if I choose to use SharePoint web services (ows_EncodedAbsUrl). Am I doing something wrong? Perhaps this is issue related to CamlDesigner.
1 Solution
Rainer JeschorCommented:
your CAML should include this in the ViewFields:
<FieldRef Name="EncodedAbsUrl" />

If you want to code it in C# / web part code then use this
string sQuery = @"<Query><Where><IsNotNull><FieldRef Name=""Title"" /></IsNotNull></Where></Query>";

string sViewFields = @"<FieldRef Name=""Title"" /><FieldRef Name=""EncodedAbsUrl"" />";

Open in new window

and set it to your SPQuery object.

I used this tool
which could also generate the C# code for the query.

tolppaAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now