Get URL of document in document library and show it in other column of same record

sharepoint.stackexchange https://sharepoint.stackexchange.com/questions/190042

  •  11-10-2020
  •  | 
  •  

Question

I have a library in which I store .doc files. I want to show URL of document in another column (say. DocumentURL).

The library should show URL of the document in DocumentURL column when new document is added to library

Please suggest ootb procedure. Thanks

Was it helpful?

Solution

You could do that with an workflow (below with an SharePoint 2010 WF) and "Set Field in Current Item". So the field would be "DocumentURL" and the value ist over "Workflow Context" available.

The column could be an "Hyperlink or Picture" column.

  1. Workflow Action

    enter image description here

  2. Properties of the action

    enter image description here

  3. If you want to start the workflow after uploading make sure the start options are set

    enter image description here

  4. The output should be similar to this

    enter image description here

If you click on that link, it will open up the .pdf file and you can also copy that link and send it via e-mail.

OTHER TIPS

if you do not want to go workflow you can refer the below link for get all metadata of doc's

Please try the CSR below:

function init() {
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
        Templates: {
            Fields: {
                "DocumentURL": {
                    View: function(ctx) {
                        return window.location.protocol + "//" + window.location.host + ctx.CurrentItem["FileRef"];
                    },
                }
            },
        },
        ListTemplateType: 101
    });
}
RegisterModuleInit(SPClientTemplates.Utility.ReplaceUrlTokens("~siteCollection/Style Library/DocURL.js"), init);
init();

You might have to change the column name ('DocumentURL') to the internal name of the corresponding column in your list.

You might have to change the URL in the RegisterModuleInit-function depending on where you upload the script and how you call the file.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top