?
Solved

CAML and document library URL

Posted on 2012-09-19
2
Medium Priority
?
1,798 Views
Last Modified: 2012-09-20
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:

   <Where></Where>
   <QueryOptions>
      <IncludeMandatoryColumns>True</IncludeMandatoryColumns>
      <IncludeAttachmentUrls>True</IncludeAttachmentUrls>
   </QueryOptions>

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.
0
Comment
Question by:tolppa
2 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 2000 total points
ID: 38419376
Hi,
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
http://spcamlqueryhelper.codeplex.com/
which could also generate the C# code for the query.

HTH
Rainer
0
 
LVL 1

Author Closing Comment

by:tolppa
ID: 38420510
Thanks.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
When using a search centre, I'm going to show you how to configure Sharepoint's search to only return results from the current site collection. Very useful when using Office 365 with multiple site collections.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month16 days, 11 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question