Getting URL to list item in list view’s JSLink

If you have specified a JSLink for your list view, how do you get the URL to the list item from within your rendering function? By URL, I mean a URL that can be used to view/display the list item.

If you look at the properties of the renderingContext.CurrentItem object, you will see that there isn’t anything that will give you the URL.

If you look at the properties of the renderingContext object itself, you will see that there are three relevant properties: displayFormUrl, editFormUrl and newFormUrl. The values of these properties however are not what you might expect. The value of displayFormUrl for example is something like http://myServer/_layouts/15/listform.aspx?
PageType=4&ListId=%7BD416B014%2DBDCA%2D4561%2D954C%2D7B43D3B66520%7D. Normally you would expect this to be more like http://myServer/Lists/myList/DispForm.aspx.

The good news is while the values of these properties look strange, they actually work. They redirect to the appropriate list form (that is display, edit or new).

So, to get the display URL for a list item, you should use the code below:

renderingContext.displayFormUrl + “&ID=” + renderingContent.CurrentItem.ID

Use the same approach to get the edit URL for the item, or the new item URL for the list.


About Bernado

Based in Australia, I am a freelance SharePoint and Dynamics CRM developer. I love developing innovative solutions that address business and everyday problems. Feel free to contact me if you think I can help you with your SharePoint or CRM implementation.
This entry was posted in JSLink, SharePoint 2013. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s