SharePoint Document Library – show Path column in the view and make it clickable to open that path

1+

How to add / show Path column in a view in a SharePoint Document Library appears to be a question with hundreds of different answers to it. The reasons for such a variety are:

  • different versions of SharePoint (on premise, online, 2010, 2013);
  • two Workflow variations (“old” workflow, Microsoft Flow);
  • SharePoint Designer (2010, 2013);
  • using Web Parts and more.

Why would one need to see a Path column? Take a look at the two examples below; however, there might be more use cases.

Example 1 – when searching for files.

Example 2 – when using a view with “Show all items without folders” option selected

Here is a test Document Library with a folder and some document in it:

It’s not possible to show Path column using out-of-the-box tools, the Path column is just not available to be selected:

Although the Path can be seen if you open the details pane:

Export to Excel query also shows it:

The information is there. Not sure why Microsoft couldn’t make that column selectable.


SOLUTION

To add the Path column to the view use SharePoint Designer 2013. Open your SharePoint site, the library, select the view where Path column needs to be added.

Unfortunately, SP Designer 2013 no longer supports the Design view, that’s why we have to work with the Code view.

The line that starts with <View Name=” is the one you should be looking for:

Within that line find a list of columns from your view that looks like this:

<FieldRef Name="..."/><FieldRef Name="..."/><FieldRef Name="..."/>

To show the Path column simply add the following part (the place where you add it is up to you), then save your view:

<FieldRef Name="FileDirRef"/>

To make the Path column clickable and open a corresponding folder, we need to apply the following JSON code to the custom formatting:

{
	"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
	"elmType": "a",
	"style": {
		"color": "blue",
		"font-weight": "bold"
	},
	"attributes": {
		"target": "_blank",
		"href": "='https://contoso.sharepoint.com' + @currentField"
	},
	"txtContent": "@currentField"
}

Don’t forget to adjust the link in the code above to match your Company one.

RESULT

1+

This Post Has 2 Comments

  1. Thanks mate, works well!

    0
  2. Awesome article – works a treat! cheers

    0

Leave a Reply

Close Menu