Field link to document. RRS feed

  • Question

  • What I am actually trying to accomplish is to make the Title field or another custom field link to a document in a document library.  Exactly how the name field works except with a more user friendly display name.

    Any assistance of guidance is greatly appreciated.

    Thank You

    Tuesday, December 8, 2015 5:49 PM


  • Hi Yotafan,

    If you want to use another field which works as the Name field, here are the detail steps:

    1.Since we cannot get the name of the document directly, we should create a list workflow to copy Name to Title field or another custom field.

    In this test, I create a “nameTolink” column to store the name of current document.

    2. Add the following java script to the page:

    (function () {
        var overrideNameField = {}; 
        overrideNameField.Templates = {};
        // This action will edit the “Title” field. You can change the “Title” to another custom column.
        overrideNameField.Templates.Fields = {
            "Title": { "View": overrideNameFieldTemplate }        
    function overrideNameFieldTemplate(ctx) { 
    var title = ctx.CurrentItem.Title;
    //”nameTolink” is column stored the name of current document.
    var fileRef = ctx.CurrentItem["nameTolink"];
    //”test” is a custom field I store the custom content. You can change it to “Title” or another custom field to fit your requirement.
        var fileLeafRef = ctx.CurrentItem["test"];
        // here the url should be of your document library. In my case it was Doc2 library.
        var url = _spPageContextInfo.webAbsoluteUrl +"/Doc2/"+ fileRef;    
            return "<a href='" + url+ "'>" + fileLeafRef + "</a>";  

    3. After completing the changes above, we can click the “Title” filed, then the document will be open. It works as the “Name” field.

    Best regards,

    Linda Zhang

    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Thursday, December 10, 2015 1:24 AM