Get URL of document in document library and show it in other column of same record
-
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
La 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.
Workflow Action
Properties of the action
If you want to start the workflow after uploading make sure the start options are set
The output should be similar to this
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.
Autres conseils
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.