I am using SharePoint Online and trying to use JS Link to override some elements of how a List view Web Part is displayed. I am finding it nearly impossible to do this... I have found numerous examples where others have done this online (even using SharePoint Online) however it is failing for me each time. The problem comes up where when I go to configure the Web Part with the JS Link and then test, it will NEVER find the Javascript file. The reason it won't find the Javascript file is that it won't look where it is supposed to. It will either take the path rather literally, or look at cdn.sharepoint.com.
So here is my example: My site is setup with a url of - http://mytenancy.sharepoint.com/sites/sitecollection/mysite/. The page that I am trying to customize the Web part for is https://mytenancy.sharepoint.com/sites/sitecollection/mysite/SitePages/Test.aspx. From here I have placed a copy of the JS in:
- https://mytenancy.sharepoint.com/sites/sitecollection/_catalog/masterpage/csr_override.js
- https://mytenancy.sharepoint.com/sites/sitecollection/mysites/SitePages/csr_override.js
- https://mytenancy.sharepoint.com/sites/sitecollection/mysites/_catalog/masterpage/csr_override.js
I have then configured the web part's JS Link property in a variety of ways such as:
- ~sitecollection/_catalog/masterpage/csr_override.js
- ~/sitecollection/_catalog/masterpage/csr_override.js
- ~sites/sitecollection/_catalog/masterpage/csr_override.js
- ~mysite/_catalog/masterpage/csr_override.js
- ~sitecollection/mysite/_catalog/masterpage/csr_override.js
Each of the above JS Link configurations will result in SharePoint failing to find the file in the following general manner:
https://mytenancy.sharepoint.com/sites/sitecollection/mysites/SitePages/~sitecollection/_catalog/masterpage/csr_override.js
On the other hand, I have also attempted to configure JS Link as below:
- /sitecollection/_catalog/masterpage/csr_override.js
- /sitecollection/mysite/_catalog/masterpage/csr_override.js
- etc.
Interestingly enough each of these will result in the application attempting to find the JS file on the CDN! In other words instead of looking on https://tenancy.sharepoint.com/sites/sitecollection/ it looks at https://cdn.sharepoint.com/....
Would anyone have an idea what is going on here and how I can fix this? I'm going insane....
Thank you in advance.