0

I would like to create a column in a custom list where the users can add hyperlinks of their documents instead of attaching them. I would like to make them able to browse casualy, just like when they add a document as an attachment, but in this case don't need to attach. I would like to add only the name of the document as a hyperlink of the path when they select the document in the browser. So if the user click on the name of the document in the item view the document should open from an external database.

In short we have a database where we store the documents so we don't need the Sharepoint as a storage, but we want to be able to open them from a custom list.

  • So the documents are in a network share? You mentioned browsing to the docs, where are they going to browse? mapped drive? – Mike2500 Sep 12 '17 at 14:25
  • Yeah, to a mapped drive. – Nefri Sep 13 '17 at 7:33
1

I do this for our product team - they needed a way to automatically browse the network shares and create the URL link to the documents.

Note, though, that those links will be coded as file:// and so can only be used through IE (and I assume Edge) - Chrome/Firefox users would have to copy/paste the link into their address bar.

This uses a jquery addin that I'm not sure exists anymore - but you might be able to use some standard HTML5 to do the same thing.

Notes on this code - it is expecting them to always pick from their O drive, so you might have to change the logic there. While a URL field will actually understand it if you leave the link as file://O: if others don't have that mapped it can be a problem - I always change the mapped drive reference back down to the actual network location.

It is writing to a URL field - you can also change the code to write anchors to a rich text field if you think they will want to reference multiple files.

Also, I've run into differences on whether to use file:// or file://// - if one of those doesn't work, try the other.

It could be that there's an HTML way of doing the <input type="file"> reference to pop up the browser and bring back the file name, but that didn't work for me then and I did this way back in SharePoint 2007 days and thought it would at least give you a reference on what is needed.

    <script src="/Javascript/JQuery/JQueryMin-1.8.2.js"></script>
    <script src="/Javascript/Utilities/jquery-custom-file-input.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {

        // browse buttons
        var fmgbtn = '<input type="button" id="fmgMLfile" name="fmgMLfile" value="Browse.." />';
        $('nobr:contains("COLUMNDISPLAYNAME")').closest('tr').find('td').eq(0).append(fmgbtn); 

        $('#fmgMLfile').file().choose(function(e, input) {
            var filename = input.val();
            if(filename.substring(0,2)== 'O:') {
                    filename = "\\\\cifs1\\FOLDERNAME\\FOLDERNAME" + filename.substring(2);
            }
            $('nobr:contains("COLUMNDISPLAYNAME")').closest('tr').find('td').eq(1).find('input').eq(0).val("file://" + filename);
            // if that doesn't work, I've got a newer structure to update a URL field for SP2013
            // $('nobr:contains("COLUMNDISPLAYNAME")').parents('tr:first').find('input:first').val("file://" + filename);
            // reference to add the name into the description
            // $('nobr:contains("COLUMNDISPLAYNAME")').parents('tr:first').find('input:last').val(YOURDOCUMENTNAME);
         });

     }); // end of document ready
    </script>
  • Thank you very much! This is what I needed exactly. I ll test it tomorrow. – Nefri Sep 13 '17 at 15:09
0

I think you can use the "Hyperlink or Picture" column or use JSLink to customize the look and action of any column in the list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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