Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am wanting to link straight to the related documents I have so I have used a LOOKUP column. This is ok until it opens in another modal box. Does anyone have a solution and if so can it be used for multiple items in a LOOKUP column?

I did ask this question 2 years ago and I am still without a response. Does anyone have a suggestion that may work?

share|improve this question
This is possible. About your lookup column, do user choose currently documents by their 'Title' ? – Sylvain Gantois Nov 18 at 2:41

1 Answer 1

2 years.. I felt I should do something to help.

Here is my solution that works for a lookup field. I didn't make it for multiple lookup although it is possible. Also I made this for SharePoint 2013, in SharePoint 2010 the REST api is different so the URL to retrieve items will change.

  • My library which contains the documents is "Documents".
  • I have a custom list called "LinkToDoc" on which I added a lookup field.
  • The lookup field is called "RelatedDoc" which points to "Documents".
  • I choose to make the lookup on "Title" field of "Documents". You don't need to add other columns from "Documents"
  • this scripts uses JQuery

You will have to use JSLink to render your list view.

Adapt the following code to your environment


    var overrideCtx = {};
    overrideCtx.Templates = {};

    // Replace by correct list template ID.
    // I used a custom list so my List template Id is 100.
    // Find your's here:
    overrideCtx.ListTemplateType = 100;

    overrideCtx.BaseViewID = 1;
    overrideCtx.Templates.Fields = {
        // My lookup field is 'RelatedDoc', replace by your field
        'RelatedDoc': { 'View' : RenderLinkToDoc }


function RenderLinkToDoc(ctx)

    var placeholderId = ctx.CurrentItem.ID;
    // Recplace 'RelatedDoc' by your field
    var docTitle = ctx.CurrentItem.RelatedDoc[0].lookupValue;

    // URL to retrieve information we need. Replace 'Documents' by your library name and 'RelatedDoc' by your field
    var reqUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Documents')/items?$filter=ID eq '" + ctx.CurrentItem.RelatedDoc[0].lookupId + "'&$select=EncodedAbsUrl";

            url: reqUrl,
            method: "GET",
            headers: { "Accept": "application/json;odata=verbose" },
            dataType: 'json',
            async: true,
            success: function (data) {
                    $('#CustomCount' + placeholderId).html('<a href="' + data.d.results[0].EncodedAbsUrl + '">' + docTitle + '</a>');
        error: function (data) {alert('error');}

    return '<div id="CustomCount' + placeholderId + '" />';

Put the javascrit in a .js file and upload it to your portal.

On "All Items" view of the list which needs to be customed ("LinkToDoc" in my case), edit the webpart and about the JSLink property point to your javascript file: ~sitecollection/style library/linktodoc.js
(you don't need to upload your file in the style library but you need to use ~sitecollection keyword)

Save the webpart and the page, then it should work.

EDIT: this will work for the list views, you will need additional javasccript if you want to do the same about an item in Display mode.

share|improve this answer

Your Answer


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

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