I created a sharepoint task list with the column "Priority" according to this guide: https://code.msdn.microsoft.com/office/Client-side-rendering-code-0a786cdd#content

Then I linked the JS, which I saved on m SharePoint under the "Miscellaneous" Part of the Web Part. Now, what the script is supposed to do, is to look for the column "priority" and replace the words "High" with a red png-picture, the words "normal" with a yellow png-picture etc...

However it seems like the JS is not working at all, because the list does not Change it appearence at all. I tried different approaches like, not replacing the words with Pictures and only changing their colours etc, however ist not working so far

Here is the full code:

(function () { 

    var priorityFiledContext = {}; 
    priorityFiledContext.Templates = {}; 
    priorityFiledContext.Templates.Fields = { 
        "Priority": { "View": priorityFiledTemplate } 



function priorityFiledTemplate(ctx) { 

    var priority = ctx.CurrentItem[ctx.CurrentFieldSchema.Name]; 

    if(priority=="High") { 
        return "<img src='/sites/020014/Name/Biblio/AmpelRed.png'/>";
    else if(priority=="Normal") { 
        return "<img src='/sites/020014/Name/Biblio/AmpelAmber.png'/>";
    else if(priority=="Low") { 
        return "<img src='/sites/020014/Name/Biblio/AmpelGreen.png'/>";


now I am wondering, maybe this part of the code:

var priority = ctx.CurrentItem[ctx.CurrentFieldSchema.Name]; 

is supposed to find the "priority" coloumn, but im not sure, how it works...

thanks in advance!

  • 1
    hello can you share the path how you are refereing in the Miscellaneous property and have tried placing alert in the script.
    – Sunil Sahu
    Aug 10, 2018 at 9:51
  • There is nothing wrong with your code. May be your JS file is not loading properly. I would recommend to try the solution provided by @Sunilsahu. That should work... Aug 10, 2018 at 17:38

2 Answers 2


think its with refering the JS file in JS link property. A simple /v.js link will not work. Either of the following SharePoint tokens should be used instead:

For js file stored in SiteCollection

~sitecollection/your file path.

like :-


And for js file stored in SubSite/Web

~site/SiteAssets/your file path.

like :-


For more tokens you may refer


Try to link your JS using a content editor webpart.

while in edit mode navigate to Insert -> Media and Content ->Content Eiditor then edit the Content Editor to pull the URL path of your saved .js file.

Your Answer

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

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