The Trick to Getting JS Link to Work in SharePoint

There have been a number of times I’ve forgotten that there’s a kind of black magic going on with the JS Link field in SharePoint List Views.  I’m writing this mostly to remind myself of how to do it properly, but also to help anyone else out there who may be running into the same issue.

Essentially, depending on where you have your JS file stored in your SharePoint site / site collection the URL will be in the form of one of two possibilities.

1) For a JS file in a local site, you would use the format:

~site/_catalogs/masterpage/[filename].js

2) And for a file in a subsite, but using the site collection’s masterpage library, you would use the following format instead:

~sitecollection/_catalogs/masterpage/[filename].js

An example (using the ~site reference) can be seen below.

SNAGHTML7d07b5f

2 responses to “The Trick to Getting JS Link to Work in SharePoint

Comments are closed.