cancel
Showing results for 
Search instead for 
Did you mean: 
emha
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

First of all, try to follow script exactly as is it this on provided link - there are no  <script> tags, SOD  wait is not needed as well.

next, make sure 'Project Status' is field's internal name and not just display name => go to list settings >> field properties and check carefully URL - somewhere at the end you should see field name. if it is anything else than 'Project%20Status' then use name from URL in your script.

next, as already suggested, while in list view open page source and search  for your script name  (without path). proof check that path resolved there fits with script path. to get script path, go to the library where you saved it and 'copy link location'

if above still doesn't help, proceed as follows

- press F12 in browser to open developer console. in the window that opens switch to console tab

- now in the browser/browser tab where you opened dev console from, open or refresh list view

- check all the errors reported in developer console. if you are not able to resolve them on your own post all of then here

Reply
thienphan
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

Hi Marina,

Please see screenshot attached. That is an error happened. I could not fix it by myself. Pls support me to do that.

0 Kudos
Reply
emha
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

it's not an error, just a warning, you can ignore this one.

what about the rest checks?

Reply
thienphan
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

Hi Marian

I checked others, its ok. Could you have a look at the code below. Is it right?

0 Kudos
Reply
emha
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

1. you have used wrong braces in OnPostRender definition

2. if you really named list field with a space in it, sharepoint converts its internal name to non-space identifier,  like Project_x0020_Status. but you have said above you have already checked this...

following was working for me

(function (){
    var overrideCtx = {};
    overrideCtx.Templates = {},

    overrideCtx.OnPostRender = [
        HighlightRowOverride
    ]
   
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx) ;
})() ;


function HighlightRowOverride (inCtx) {
    // for each item (row)
    for (var  i = 0; i < inCtx.ListData.Row.length; ++i){
        var listItem =inCtx.ListData.Row[i];
        var iid = GenerateIIDForListItem(inCtx,listItem); 
        var row = document.getElementById(iid);
       
        if ( listItem.Project_x0020_Status == "Handover"){
          if (row != null)
              row.style.backgroundColor = "rgba(255,0,0,0.5)";
        }
    }
    inCtx.skipNextAnimation =true;
}
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Reply
thienphan
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

Hi Marina,

I already change the braces at you mentioned. Actually, I change "Project Status" field to "Status" to make it simple. And then I used the code :if ( listItem.Status== "Handover"). I check the properties of Status field, Screenshot is what I see

0 Kudos
Reply
emha
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

if you only rename list field it's internal name doesn't change.

Can you remove the field and create it once again with new name?

Reply
thienphan
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

Hi,

I deleted the field, and created the new one named as Status. I don't know how to check whether it is internal name or not?

0 Kudos
Reply
emha
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

I've explained it above, URL shows internal name.

next, make sure 'Project Status' is field's internal name and not just display name => go to list settings >> field properties and check carefully URL - somewhere at the end you should see field name. if it is anything else than 'Project%20Status' then use name from URL in your script.

but if you created new column with no space or other special characters internal name should fit to display name.

Reply
thienphan
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

hi ,

I just tested the code by searching the link of Java code in, I copied it and pasted in in JS Link under Miscellaneous section. After that, the list can not be displayed anymore. What should I do to solve that?

0 Kudos
Reply