0

I have a Choice column (Yes,No) and the default value is blank. I can get the Yes/No values easily and change the colors (Green/Red) but I need the 'Blank' value to be white. I need help with this 3rd condition. The column is called "Move_x0020_batching_x0020_proces" I have my code below:

{
  "elmType": "div",
  "style": {
    "box-sizing": "border-box",
    "padding": "0 2px"
  },
  "attributes": {
    "class": {
      "operator": ":",
      "operands": [
        {
          "operator": "==",
          "operands": [
            "[$Move_x0020_batching_x0020_proces]",
            true
          ]
        },
        "sp-css-backgroundColor-successBackground",
        "sp-css-backgroundColor-errorBackground"
      ]
    }
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "line-height": "16px",
        "height": "14px"
      },
      "attributes": {
        "iconName": {
          "operator": ":",
          "operands": [
            {
              "operator": "==",
              "operands": [
                "[$Move_x0020_batching_x0020_proces]",
                true
              ]
            },
            "",
            ""
          ]
        }
      }
    },
    {
      "elmType": "span",
      "style": {
        "overflow": "hidden",
        "text-overflow": "ellipsis",
        "padding": "0 3px"
      },
      "txtContent": "=if(@currentField == true, 'Yes', if(@currentField == false,'No',''))",
      "attributes": {
        "class": {
          "operator": ":",
          "operands": [
            {
              "operator": "==",
              "operands": [
                "[$Move_x0020_batching_x0020_proces]",
                true
              ]
            },
            "",
            ""
          ]
        }
      }
    }
  ]
}
3
  • What is the data type of your column? Is it a Choice or Yes/No (Boolean) column? Jul 13 '20 at 14:58
  • It is a Text (Choice) field as in "Yes" or "No" with a default of blank. So also need to check for blank and Not color it at all.
    – Bismarck
    Jul 13 '20 at 15:07
  • It's like I need 3 IF statements at: "if(@currentField" I think
    – Bismarck
    Jul 13 '20 at 15:12
0

I figured it out. Here is the code to share with anyone else

    {
  "elmType": "div",
  "style": {
    "box-sizing": "border-box",
    "padding": "0 2px"
  },
  "attributes": {
    "class": {
      "operator": ":",
      "operands": [
        {
          "operator": "==",
          "operands": [
            "[$Move_x0020_batching_x0020_proces]",
            "YES"
          ]
        },
        "sp-css-backgroundColor-successBackground30",
        {
          "operator": ":",
          "operands": [
            {
              "operator": "==",
              "operands": [
                "[$Move_x0020_batching_x0020_proces]",
                ""
              ]
            },
            "",
            {
              "operator": ":",
              "operands": [
                {
                  "operator": "==",
                  "operands": [
                    "[$Move_x0020_batching_x0020_proces]",
                    "NO"
                  ]
                },
                "sp-css-backgroundColor-blockingBackground30",
                "sp-css-backgroundColor-neutralBackground"
              ]
            }
          ]
        }
      ]
    }
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "line-height": "16px",
        "height": "14px"
      },
      "attributes": {
        "iconName": {
          "operator": ":",
          "operands": [
            {
              "operator": "==",
              "operands": [
                "[$Move_x0020_batching_x0020_proces]",
                "YES"
              ]
            },
            "",
            {
              "operator": ":",
              "operands": [
                {
                  "operator": "==",
                  "operands": [
                    "[$Move_x0020_batching_x0020_proces]",
                    ""
                  ]
                },
                "",
                {
                  "operator": ":",
                  "operands": [
                    {
                      "operator": "==",
                      "operands": [
                        "[$Move_x0020_batching_x0020_proces]",
                        "NO"
                      ]
                    },
                    "",
                    ""
                  ]
                }
              ]
            }
          ]
        }
      }
    },
    {
      "elmType": "span",
      "style": {
        "overflow": "hidden",
        "text-overflow": "ellipsis",
        "padding": "0 3px"
      },
      "txtContent": "[$Move_x0020_batching_x0020_proces]",
      "attributes": {
        "class": {
          "operator": ":",
          "operands": [
            {
              "operator": "==",
              "operands": [
                "[$Move_x0020_batching_x0020_proces]",
                "YES"
              ]
            },
            "",
            {
              "operator": ":",
              "operands": [
                {
                  "operator": "==",
                  "operands": [
                    "[$Move_x0020_batching_x0020_proces]",
                    ""
                  ]
                },
                "",
                {
                  "operator": ":",
                  "operands": [
                    {
                      "operator": "==",
                      "operands": [
                        "[$Move_x0020_batching_x0020_proces]",
                        "NO"
                      ]
                    },
                    "",
                    ""
                  ]
                }
              ]
            }
          ]
        }
      }
    }
  ]
}
0

To check blank value for choice column you can use below condition:

=if([$ChoiceCol], 'Not Blank', 'Blank') 

OR

=if([$ChoiceCol] == '', 'Blank', 'Not Blank')
4
  • How would that look on this line, assuming this is where to put it? "txtContent": "=if(@currentField == true, 'Yes', if(@currentField == false,'No',''))",
    – Bismarck
    Jul 13 '20 at 15:20
  • Are you adding this JSON on same choice column? Or is it another column and you need merge these two conditions (old one you are using and the new one I am suhh8)? Jul 13 '20 at 15:37
  • I figured it out and posted my answer. Thanks for your help.
    – Bismarck
    Jul 13 '20 at 15:42
  • Welcome. Glad you figured it out. Jul 13 '20 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.