2

Environment: Sharepoint 2013, using a Sharepoint list

Have a simple JSLink script located in ~site/Style Library/JSLink/ that applies coloring to a specific list field (RAG Status) depending on its value:

    (function () {
         var columnCtx = {};
         columnCtx.Templates = {};
         columnCtx.Templates.Fields = {
             "RAG_x0020_Status":
              {
                  "View": DisplayApprovalStatus
              }
          };
          SPClientTemplates.TemplateManager.RegisterTemplateOverrides(columnCtx);
    }) ();
    
    var green="<span style='color:#01DF3A'>Green</span>";
    
    function DisplayApprovalStatus(ctx) {
         var columnValue = ctx.CurrentItem.RAG_x0020_Status;
         var statusIndicator = "";
    
         if (columnValue == "(1) Green")
             statusIndicator = green;
    
         return statusIndicator;
    }

This script works when I load the site, but when others load it from within the same org, it doesn't render at all, instead leaving the same "(1) Green" rather than a green-colored "Green".

I have checked and several testers have the same permission levels for the sharepoint site as I do. Any ideas to get this working globally would be appreciated!

5
  • Does the JS not appear in the DOM at all? E.g. if the user's F12, they won't see your JS at all. Dec 18, 2020 at 22:36
  • Checked one of the users, the .js file is indeed referenced in the DOM, the same as when I check on my own.
    – Adder
    Dec 18, 2020 at 23:23
  • Any errors in the console when it's executed on the test users browser? Dec 18, 2020 at 23:42
  • Wasn't able to find any errors from the user side, but when I tried wrapping in <script> tags and putting the script into a Script Editor WP, it worked the way it was supposed to. Seems to indicate something with the script location or access permissions to me. Not the ideal answer, but it works for the time being.
    – Adder
    Dec 19, 2020 at 0:01
  • try to test it with alert();.Did users click on ctrl - f5 ?
    – Raf
    Dec 19, 2020 at 11:21

1 Answer 1

2

Looks like it's a JS Cache issue! so I suggest to do the following:

  • Create a new JSLink file with a different name.
  • Make sure that the newly created file is checked-in and published.
  • Next time you would like to change this file, try to rename it with a unique file version identifier like "filenameVx" where x is the new version number to perform cache-busting manually that will tell the browser that a new version of the file is available, and the browser will read the new file and don't retrieve the old file from the cache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.