SharePoint 2013 Script to update Title link with URL and ID

SharePoint 2013 Script to update Title link with URL and ID

So I needed to create a list data view and have the items title link to a fixed URL path with the item’s ID at the end as a query string parameter.
In SharePoint 2010 I would get this done in SharePoint Designer, adding an empty data view
and editing its XSL.
In 2013 I wanted to do this using JSlink but I found it more complicated than I thought it would be, and I was short on time, so I wrote this simple script that grabs the ID from the last column of the data view and updated the href attribute of the first data view column –

{code type=javascript}

{/code}

In order to get the above script to work make sure:
1. Your SharePoint site has a jQuery reference.
2. Your Data View first column is the title or any other column you want to use as a link.
3. Your Data View last column is the item’s ID.
4. Update the variable “urlPath” with your own path.
5. Update the variable “listName” with your own list’s name.

Leave a Reply

Your email address will not be published. Required fields are marked *

* Copy This Password *

* Type Or Paste Password Here *