locked
SharePoint Online Format Date Column Ignore Blank - Adapting JSON RRS feed

  • Question

  • HI

    I don't know how to write JSON code but wanted to achieve this so thought I could use the out of the box and adapt the JSON but unsure how.  Appreciate some help here please.

    What below does: If date before Today, turn green.

    What is the issue: turns blank cells green also.

    What I want: If date before Today, turn green but ignore blanks.

    {
      "elmType": "div",
      "style": {
        "box-sizing": "border-box",
        "padding": "0 2px"
      },
      "attributes": {
        "class": {
          "operator": ":",
          "operands": [
            {
              "operator": "<",
              "operands": [
                {
                  "operator": "Date()",
                  "operands": [
                    {
                      "operator": "toDateString()",
                      "operands": [
                        {
                          "operator": "Date()",
                          "operands": [
                            "[$M_x0026_E_x0020_Launch_x0020_Dat]"
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "operator": "Date()",
                  "operands": [
                    {
                      "operator": "toDateString()",
                      "operands": [
                        {
                          "operator": "Date()",
                          "operands": [
                            "@now"
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            "sp-css-backgroundColor-successBackground40 sp-field-iconRightAligned",
            ""
          ]
        }
      },
      "children": [
        {
          "elmType": "span",
          "style": {
            "line-height": "16px",
            "height": "14px"
          },
          "attributes": {
            "iconName": {
              "operator": ":",
              "operands": [
                {
                  "operator": "<",
                  "operands": [
                    {
                      "operator": "Date()",
                      "operands": [
                        {
                          "operator": "toDateString()",
                          "operands": [
                            {
                              "operator": "Date()",
                              "operands": [
                                "[$M_x0026_E_x0020_Launch_x0020_Dat]"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "operator": "Date()",
                      "operands": [
                        {
                          "operator": "toDateString()",
                          "operands": [
                            {
                              "operator": "Date()",
                              "operands": [
                                "@now"
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                "Accept",
                ""
              ]
            }
          }
        },
        {
          "elmType": "span",
          "style": {
            "overflow": "hidden",
            "text-overflow": "ellipsis",
            "padding": "0 3px"
          },
          "txtContent": "[$M_x0026_E_x0020_Launch_x0020_Dat.displayValue]",
          "attributes": {
            "class": {
              "operator": ":",
              "operands": [
                {
                  "operator": "<",
                  "operands": [
                    {
                      "operator": "Date()",
                      "operands": [
                        {
                          "operator": "toDateString()",
                          "operands": [
                            {
                              "operator": "Date()",
                              "operands": [
                                "[$M_x0026_E_x0020_Launch_x0020_Dat]"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "operator": "Date()",
                      "operands": [
                        {
                          "operator": "toDateString()",
                          "operands": [
                            {
                              "operator": "Date()",
                              "operands": [
                                "@now"
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                "sp-field-bold",
                ""
              ]
            }
          }
        }
      ]
    }

    thank you!

    Friday, December 4, 2020 10:58 AM

Answers