JSLink SharePoint 2013 troubleshooting

JsLink is a good feature that was introduced in SP 2013 to allow users to bring in more flexibility in Client Side Rendering (CSR). With this you can control how your list data is getting displayed in View, Display, Edit and New forms.

For ex., you can achieve this using JSLink:



You can check the implementation here: JSLink Custom JS Rendering Tutorial


The JS Link was still not working and the list view remained the same.


Check the URL you defined in your JSLink webpart property (under Miscellaneous). You need to define the URL as: ~site/Site Assets/xyz.js” instead of defining the absolute or relative URL of your js file. It should always begin with a given set of URL tokens and then your file path. JsLink URL can begin with either of the following URL tokens: ~site, ~sitecollection, ~layouts, ~sitecollectionlayouts or ~sitelayouts only. Absolute paths will break the JsLink functionality.


MDS (Minimal Download Strategy) strategy having issues. Try using RegisterModuleInit(“{file URL}”, MyJsMethod); to register the JSLink. Check this link.

Also, as a best practice, its recommended to specify the SharePoint CSR filename in the JS Link URL.

ex. The JSLink URL for Tile View in Promoted Links would look like:

sp.ui.tileview.js | ~site/SiteAssets/xyz.js

SharePoint 2013: Log Analytics through javascript

The following code snippet will help you to log the usage analytics into ULS:

//Log Views usage event on URL of catalog item
    window.LogViewsToEventStore = function(url, site)
        SP.SOD.executeFunc(“sp.js”, “SP.ClientContext”, function()
            var spClientContext = SP.ClientContext.get_current();
                    var spWeb = spClientContext.get_web();
                    var spUser = spWeb.get_currentUser();
                    var spScope = “{00000000-0000-0000-0000-000000000000}”;
                    //Event ID = 1 (Views), 2 (
                    SP.Analytics.AnalyticsUsageEntry.logAnalyticsEvent2(spClientContext, 1, url, spScope, site, spUser);spClientContext.executeQueryAsync(null, null);                   
    LogViewsToEventStore(‘Url’, ‘SiteID’);

You can use this in your CSWP or other webparts on client side, with ease.