Contents
The easiest way is for the user to open a task in the display form and she/he will be able to view the task details plus a field called Related Items that offers a link to the document.
SharePoint 2013 Task forms have a pretty nifty field called Related Items. It allows you to add a reference to another document or site asset to a Task. This is mainly used to display the related item that the task is created for (During a Workflow). Clicking on Add Related Item link and you get a dialog that allows you to
How to show link to document in task list?
If you really want to show the link to the document in the workflow tasks list view (s), then you could modify the CSR (Client Side Rendering) of the view using JS and JSLink property of the view webpart. See an example on how to do this here.
Is there a way to show all related items?
However, if you have 2 tasks on the page with more than 4 related items on each, the “Show More” button does not function properly and prevents you from seeing all of the related items that are in the Display Form. Therefore, use the below script to show all the related items for all visible tasks:
How to use jslink on a SharePoint list?
On a high level, with our code, we will need to make sure to do the following: Sharepoint’s JSlink feature on a list WebPart gives us direct access to the list and the items in it. So your JavaScript code will get passed the elements in the list.
What do you need to know about jslink?
JSLink is a property that controls rendering of fields, items and even Web Parts through a JavaScript file. This article will explore the use of JSLink with the help of two demo scenarios. The first scenario will demonstrate how you can use color-coded messages to indicate task completion, for example, as shown in Figure 1.