Need to compare time and if its not following order then color of box should change

Need to compare time and if its not following order then color of box should change to Red(using TagField).

Eg: I have to compare between T1,T2,T3,T4,T5,T6 Field Whose value am getting from database( T1=10:30,T2=10:35,T3=10:40,T4=10:45,T5= 10:50, T6=10:55)

10:30<10:35<10:40<10:45<10:50<10:55. My doubt is how to compare the timing since am getting it from Db.

10:30<10:35<10:32-- T3 box color should change to Red.

  Discussion posts and replies are publicly visible

  • You can probably do something like this:

     

    a!localVariables(
      local!data: {
        a!map(time: time(10, 30, 0)),
        a!map(time: time(10, 35, 0)),
        a!map(time: time(10, 40, 0)),
        a!map(time: time(10, 32, 0)),
        a!map(time: time(10, 45, 0)),
        a!map(time: time(10, 50, 0))
      },
      a!tagField(
        tags: a!forEach(
          items: local!data,
          expression: a!tagItem(
            text: fv!item.time,
            backgroundColor: if(
              fv!item.time > index(local!data.time, fv!index - 1, time(0, 0, 0)),
              "ACCENT",
              "NEGATIVE"
            )
          )
        )
      )
    )

    Basically the key is that you have to compare one item to the previous one in the list. When using a!forEach(), fv!index returns the index of the current item, so the previous one is fv!index - 1.