none
Get link to item/Document

    Question

  • Before turning on Document ID feature I was able to get link to document/list item in sharepoint online but once Document ID feature is turned it always displays link to document/item in terms of document id. This is not useful when I want to create links to items and documents because putting document id link in links list takes user to search page with that document/item being displayed in search result. 

    In previous versions of sharepoint (i.e. 2010), I used to right click on item/document to get link address but this doesnt seem be an option anymore in sharepoint online because right clicking an item/document opens up sharepoint menu instead of default browser menu which gives option of copy link address.

    Is there a way I can get link address without document id url in sharepoint online ? I end up typing urls for every link, which doesnt seem to be good option


    Dhaval Raval


    • Edited by DelIT Tuesday, March 21, 2017 4:34 PM Edit
    Tuesday, March 21, 2017 2:14 PM

All replies

  • Hi Dhaval Raval,

    If we use Document ID feature, all links for the documents will include the document id.

    To get the link address without the document id (such as: https://domain/sites/site/document/file.docx), we can use the SharePoint Designer workflow to get “Encoded Absolute URL” for item.


    Another workaround, use JavaScript to get the paths of items.

    (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 }        
    
     
    
        };   
    
     
    
     
    
        SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideNameField);
    
     
    
     
    
    })();
    
     
    
    function overrideNameFieldTemplate(ctx) {
    
     
    
                    var title = ctx.CurrentItem.Title;
    
     
    
                    // here the url should be of your document library. In my case it was Doc1 library.
    
                    // ctx.CurrentItem.FileLeafRef is the file name, such as "file.docx"
    
                    //var url = _spPageContextInfo.webAbsoluteUrl +"/Doc1/"+ ctx.CurrentItem.FileLeafRef;
    
     
    
                    //ctx.CurrentItem.FileRef id the relative path of file, such as "sites/site/doc1/file.docx"
    
                    var url = ctx.CurrentItem.FileRef;             
    
                   
    
                    //return the value as you want
    
                    //return url;
    
                    return "<a href='" + url+ "'>" + ctx.CurrentItem.FileLeafRef + "</a>"; 
    
     
    
    }


    Best Regards,

    Linda Zhang


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

    Wednesday, March 22, 2017 7:46 AM
  • Yes but this doesnt provide solution to overall sharepoint online getting actual URLs of items/Documents. We cant create/attach workflows every time we create list/libraries/sites. Also we do not want to list all item URLs using javascript. This is on ad hoc basis where it is decided to create list of links on several sites which could be random. I think microsoft should provide this feature as it impacts usability of Sharepoint. On right click they should provide option of get absolute url. This would solve problem of users needing absolute URLs rather then them needing to write workflows and scripts everytime they need absolute URLs for links.


    Dhaval Raval

    Wednesday, March 22, 2017 1:10 PM
  • Hi Dhaval Raval,

    Currently in SharePoint Online, links for the files will be changed to the links with Document IDs after enabling Document ID feature.

    For this issue, I suggest you submit a feedback to the SharePoint platform:

    https://sharepoint.uservoice.com/

    UserVoice is a platform for getting thoughts about Microsoft Office products. We’re eager to hear your feedback and use it to continuously provide the best intranet in your pocket.

    Best Regards,

    Linda Zhang


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

    Thursday, March 23, 2017 1:23 PM