locked
Update colour of entity date due to conditions (HTML Client) RRS feed

  • Question

  • Hi,

    Have a list with addresses and every address has a date (next inspection)

    Everything works great but I want the date to be red if it gets past today and green if its Before today.

    Tried:

    var entity = contentItem.value;
    
    if (entity > New Date()) {
    
    $(element).css({ 'color': 'green' });
     } else {
      $(element).css({ 'color': 'red' });
      }

    This is not working. Do I have to format the date or something or is my code wrong?

    regards

    Sven


    Sven Elm

    Monday, April 29, 2013 10:41 AM

Answers

  • Hi Sven,

    Can you check if var entity is a Date object, or it's an Address Object and you need to use a property name to get the Address' Next Inspection Date?

    Set a breakpoint on if (entity > New Date()) { and look at entity in the Watch window. Is it a Date object, or do you need to use entity.NextInspectionDate (assuming that's how you name the Date on your Address object) to get the Date object?

    Also, New Date() should be new Date().

    Best regards,
    Huy Nguyen

    • Marked as answer by Sven Elm Monday, April 29, 2013 6:01 PM
    Monday, April 29, 2013 5:28 PM

All replies

  • Hi Sven,

    Can you check if var entity is a Date object, or it's an Address Object and you need to use a property name to get the Address' Next Inspection Date?

    Set a breakpoint on if (entity > New Date()) { and look at entity in the Watch window. Is it a Date object, or do you need to use entity.NextInspectionDate (assuming that's how you name the Date on your Address object) to get the Date object?

    Also, New Date() should be new Date().

    Best regards,
    Huy Nguyen

    • Marked as answer by Sven Elm Monday, April 29, 2013 6:01 PM
    Monday, April 29, 2013 5:28 PM
  • Hi,

    It´s working now.

    So stupid when I set new to New......

    Thanks for pointing it out. I thought I was going crazy because Its so easy.

    regards

    Sven


    Sven Elm

    Monday, April 29, 2013 6:01 PM