How to highlight a table row based on a date?

Gary Bailey
edited November 28, 2017 in Questions
I'm not at versed in Javascript but can usually hack my way around...however, I'm having an issue with a HighlightRow snipped based on an opportunity expiration date.  

I've successfully created a row highlight snipped based on a specific value in the past (using  (field.mode == 'readonly' && value === "P")  but I don't know how to write an argument that would change use a date.  

Here is my HighlightRow snippet that changes a row color when a cell value contains "P":
var field = arguments[0],     value = skuid.utils.decodeHTML(arguments[1]);     skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);     if (field.mode == 'readonly' && value === "P")         {             field.item.element.addClass("LeadTab_highlighted-row");          }  

How can I write a snippet that applies a Class when a date in a cell is less than today's date?




  • Matt Sones
    Matt Sones 💎💎💎
    edited February 10, 2017
    You should be able to use something like this:
    var field = arguments[0], 
    value = skuid.utils.decodeHTML(arguments[1]),
    jsDateValue = skuid.time.parseSFDate(value); skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);
     if (field.mode == 'readonly' && (jsDateValue < new Date() )) { field.item.element.addClass("LeadTab_highlighted-row");
  • Gary Bailey
    edited November 28, 2017
    Thanks for taking a look at this!  

    I'm getting this error:
    Uncaught TypeError: skuid.utils.parseSFDate is not a function
  • Matt Sones
    Matt Sones 💎💎💎
    edited December 7, 2016
    Sorry about that. I edited the comment right after I posted it. It should be skuid.time...
    It's corrected above.
  • Gary Bailey
    edited November 28, 2017
    Ok, no is applying the class but now it's not changing the color of the row.  

    Here is my CSS:
    tbody.nx-skootable-data tbody tr.LeadTab_highlighted-row  {                    
       background-color: #F05423;
    Here is Matt's snippet:
    var field = arguments[0], value = skuid.utils.decodeHTML(arguments[1]),
    jsDateValue =  skuid.time.parseSFDate(value);
     if (field.mode == 'read' && (jsDateValue < new Date() )) 
    Again, I'm successfully using this on other pages with that I don't think the issue is with the CSS.  

  • Matt Sones
    Matt Sones 💎💎💎
    edited February 10, 2017
    Try this instead for the css:

    table.nx-skootable-data tbody tr.LeadTab_highlighted-row td {    
       background-color: #F05423;
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!