I'm trying to make the title of a Sharepoint 2013 list clickable to open a document:

    <FieldRef Name="Title" />
    <FieldRef Name="Project"/>
    <FieldRef Name="X"/>
    <FieldRef Name="Y"/>
    <FieldRef Name="Z"/>

It is suggested on many sites (and StackOverflow) to add "linkToItem" to the FieldRef, this works but links to the item properties instead of opening documents directly.

2 Answers 2


If you have reference to the field schema, you can set its display CAML to be a link that has an "onclick" event. If you do not have access to the field Schema, then you could use SharePoint Designer and modify the XSL of the list view web part to create the link.

 <a href="#" onclick="OnClickIDField('ID Field Text')">ID Field Text</a>

In the onclick event you call a javascript function that you would have to include on the page or in a loaded javascript file that uses REST to find and open the document. It would be easiest to use jquery (add a reference to a jquery version in your master page or the page where the list is displayed: ) to use AJAX to make the rest call.

The REST URL to find a document that contains a string is this:

http://sharepointserverurl/[path to site]/_vti_bin/listdata.svc/[title of Document library]?$select=Name,Path&$filter=substringof('Report',Name)%20eq%20true The Path property contains the relative path to the document's folder and you would have to append "/" and the Name property to it to get the document URL.

So the OnClickIDField function might look like this:

function OnClickIDField(docID) {
        url: "/_vti_bin/listdata.svc/Documents?$select=Name,Path&$filter=substringof('"
+ docID + "',Name)%20eq%20true",
        type: "GET",
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: function (data) {
            if (data.d.results != undefined && data.d.results.length > 0 && data.d.results[0].Path != undefined) {
                window.document.location.href = data.d.results[0].Path + "/" + data.d.results[0].Name;
        error: function (data) {
            // error handler
    return false; }

This is works to open document on click of linkToItem


I solved this to use a calculated column:

=CONCATENATE("<a href='http://....../_layouts/15/DocIdRedir.aspx?ID="&[Document ID Value]&"'>"&[Title]&"</a>")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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