Situation: I would like to see Related Tasks, Related Discussions and any other related items for Each document that I have in my document library. And if I click on Add New Task while I am working with a Document, I want the task to associate itself to that document automatically.
Step 1 – Create a Document Library
Step 2 – Create a Task List, Discussion List and/or any other List you wish to have.
Step 3 – In each of these Lists we will create a New Lookup Column called “DocumentID” that will lookup the Document library created in step 1. For this I chose the ID column to lookup but you can choose anything you want provided their will always be content in this field
* Great! Now we have something linking all these lists together
Step 4 – Now we will Edit the “Default Display Form” of the document library to add our Related Lists Web Parts in the page.
*Note* Advanced users may want to go to SharePoint Designer and create a new Custom Display Form with a Custom Action
Step 5 – Test! Now we should be able to click on “View Properties” of a document and see the Related Tasks and other items you’ve added.
*Oops, when we click on Add a New Item from this page, the lookup column doesn’t get automatically selected to the current document we are on… let’s fix that!
To fix this, we will need the help of JQuery but don’t worry! no coding is necessary 🙂
Step 6 – First create a Folder somewhere, I created a folder called custom-scripts under the “Style Library” and upload these files in the folder. These 2 files are the JQuery library and the script that will find which document we are currently working on.
Step 7 – Now we need to tell the Lists that when someone wants to create a new item, to check which document they are working with and select the right choice in the lookup column. For that we will EDIT the “New Item Form” of these lists and Add the following code in the HTML of a content Editor Web Part.
**Make sure that the code links to the location of your files and that it references the name of your column (Last line of code, mine is DocumentID)
Here is the code as well. Again make sure you edit the links to your files and lookup column name.
Step 8 – Done! Now play with the CSS and you can make it look exactly the way you want. I placed the Tasks and Discussions on the right of the document properties. You can ever add web parts on your page!