How to show date difference in record type based on condition

Hi,

I want to display the difference between today's date and created date in record type as an integer value. Further, I want to show the value in certain colors based on condition (like if the values is less than 3 then green color; if the values are in between 3 and 5 then yellow; and if the values are greater than 5 then red). This values will only come when the status is not completed.

Can somebody guide me?.

Many thank,

  Discussion posts and replies are publicly visible

Parents Reply
  • for color handling ->

    a!localVariables(
      local!data: {
        a!map(id: 1, date: todate("1/02/2024")),
        a!map(id: 2, date: todate("1/12/2024")),
        a!map(id: 3, date: todate("1/17/2024"))
      },
      {
        a!richTextDisplayField(labelPosition: "COLLAPSED", value: {
          a!forEach(
            items: local!data,
            expression: a!richTextItem(
            text: {concat(tointeger(today()-fv!item.date)," Days left"),char(10)},
            color: if(
              tointeger(today()-fv!item.date)<=3,
              "POSITIVE",
              if(
                tointeger(today()-fv!item.date)<=15,
                "STANDARD",
                "NEGATIVE"
              )
            )
          ))
        })
      }
    )

Children
  • Hi Amaan,

    Thank you for providing your insights. 

    I have modified the code little bit and now it is giving me the desired result.

    a!localVariables(
      local!values: {if(
        tointeger(rf!riskAssessmentStatus.id)<5,
        tointeger(today()-rf!createdOn),"NA"
      )},
      {
        a!forEach(
          items: local!values,
          expression: a!richTextItem(
            text: fv!item,
            color: if(
              fv!item = "NA","STANDARD",
              if(
                fv!item >= 6, "NEGATIVE",
                if(
                  fv!item <= 3, "POSITIVE","#FFFF00"
                )
              )
            )
          )
        )
      }
    )