1

I use lookup fields a lot and they are great. One thing I've noticed from SharePoint 2010 through to Office 365 is that when I use a lookup to point to a document set and click on the link it doesn't go directly to the document set. In the case of Office 365 it looks like this: enter image description here

When you click on the link in the project documents column you get a pop up box that you click on that will take you to the document set: enter image description here

Is there a way to click on the link on the link that references the document set in my list so that it goes directly to the document set, without the popup box?

3
+50

This can be done with the following jslink code:

    (function () {
        var linkFieldContext = {};
        linkFieldContext.Templates = {};
        linkFieldContext.Templates.Fields = 
        {
            //TODO:
            //Change "DS" to the name of your lookup column
            "DS": { "View": DocumentSetLink }
        };
        SPClientTemplates.TemplateManager.RegisterTemplateOverrides(linkFieldContext);
    })();

    //TODO:
    //Change to the url of the library that contains document sets 
    var myDocumentSetLibraryUrl = "/sites/projects/playground/Biblioteka1/";

    function DocumentSetLink (ctx) {
      var dsLinkArray = [];
  var lookupField = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];

  if (lookupField.length > 0) {
      var lookupValue = lookupField[0].lookupValue;
      var dsLinkUrl = myDocumentSetLibraryUrl + "Forms/Document%20Set/docsethomepage.aspx?RootFolder=" + myDocumentSetLibraryUrl + lookupValue;
      var dsLink = "<a href = '"+dsLinkUrl+"'>" + lookupValue + "</a>";
      dsLinkArray.push(dsLink);
      return dsLinkArray.join('');
  }
  return "";
    }

There are a couple of things that should be done to make this work:

  1. Edit the url of your library and the name of your lookup field in the script and save it as jslink1.js
  2. Upload the script to a library (the best place is the "Site Assets" library in the site that contains your list and library with document sets)
  3. Edit the page that contains your list
  4. Edit the web part that shows your list data and go to Miscellaneous. Find the "JS Link" textbox and paste the url of the script file ~site/siteassets/jslink1.js (if you didn't follow my suggestion related to assets library and file name change it accordingly)
  5. Close the edit web part (click to OK) and edit page (click to "Stop Editing").
| improve this answer | |
  • Sorry Damjan, I'm still getting the same experience of the intermediate window popping up to get to the document set. – Steve Morley Jan 17 '17 at 14:16
  • Hi Steve, could you please check the name of the lookup column (in my example it is the line: "DS": { "View": DocumentSetLink }). I see from your screenshot that the name of your column is "Project Documents", so that part of the script should be changed to : "Project_x0020_Documents": { "View": DocumentSetLink } (because the name contains the space character) – Damjan Tomic Jan 17 '17 at 15:17
  • No not quite there yet. I created a new lookup field called "documentation". My changes in the script are now: "Documentation": { "View": DocumentSetLink } and var myDocumentSetLibraryUrl = "/sites/med/ugme/mgmt/projects"; – Steve Morley Jan 17 '17 at 15:29
  • Could you please check the case of your column name (if it is "documentation", then the script should be updated accordingly): "documentation": { "View": DocumentSetLink } – Damjan Tomic Jan 17 '17 at 15:50
  • Field name and in script are the same. Still not working. – Steve Morley Jan 17 '17 at 17:47

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.