1

I would like to use a If condition to execute a different flow. Everytime the column "Aprovado Interno" is null calls one flow, else calls the other.

However I am having difficulties to apply the null statement, as the column is a Datetime format.

Below is the JSON I am using:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "button",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "='{\"id\": \"' + if([$Aprovado_x0020_Interno]: (Datetime?)null,'e40f1536-4727-41f7-8ee7-2ac5f9f38b3d','e40f1536-4727-41f7-8ee7-2ac5f9f38b3d') + '\"}'"
  },
  "attributes": {
    "class": "='ms-fontColor-' +if([$Aprovado_x0020_Interno]: (Datetime?)null,'orangeLight','teal')"
  },
  "style": {
    "border": "none",
    "background-color": "transparent",
    "cursor": "pointer"
  },
  "children": [
    {
      "elmType": "span",
      "attributes": {
        "iconName": "=if([$Aprovado_x0020_Interno]: (Datetime?)null,'Lightbulb','Deploy')"
      },
      "style": {
        "padding-right": "6px"
      }
    },
    {
      "elmType": "span",
      "txtContent": "=if([$Aprovado_x0020_Interno]: (Datetime?)null,'Solicitar cliente','Solicitar DEV')"
    }
  ]
}
0

You can just check empty string rather than null, here is modified formatting, also there was syntax error to check if condition you have to use == operator and not ':'

   {
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "button",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "='{\"id\": \"' + if([$Aprovado_x0020_Interno] == '','e40f1536-4727-41f7-8ee7-2ac5f9f38b3d','e40f1536-4727-41f7-8ee7-2ac5f9f38b3d') + '\"}'"
  },
  "attributes": {
    "class": "='ms-fontColor-' +if([$Aprovado_x0020_Interno] == '','orangeLight','teal')"
  },
  "style": {
    "border": "none",
    "background-color": "transparent",
    "cursor": "pointer"
  },
  "children": [
    {
      "elmType": "span",
      "attributes": {
        "iconName": "=if([$Aprovado_x0020_Interno] == '','Lightbulb','Deploy')"
      },
      "style": {
        "padding-right": "6px"
      }
    },
    {
      "elmType": "span",
      "txtContent": "=if([$Aprovado_x0020_Interno] == '','Solicitar cliente','Solicitar DEV')"
    }
  ]
}
0

I found the solution with the below statement.

As a Date is struct and has a default value, I converted the Date Column to a String to check the NULL value, using a "toString" method.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "button",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "='{\"id\": \"' + if(toString([$Aprovado_x0028_CLIENTE_x0029_]) == '','e40f1536-4727-41f7-8ee7-2ac5f9f38b3d','e40f1536-4727-41f7-8ee7-2ac5f9f38b3d') + '\"}'"
  },
  "attributes": {
    "class": "='ms-fontColor-' +if(toString([$Aprovado_x0028_CLIENTE_x0029_]) == '','orangeLight','teal')"
  },
  "style": {
    "border": "none",
    "background-color": "transparent",
    "cursor": "pointer"
  },
  "children": [
    {
      "elmType": "span",
      "attributes": {
        "iconName": "=if(toString([$Aprovado_x0028_CLIENTE_x0029_]) == '','Lightbulb','Deploy')"
      },
      "style": {
        "padding-right": "6px"
      }
    },
    {
      "elmType": "span",
      "txtContent": "=if(toString([$Aprovado_x0028_CLIENTE_x0029_]) == '','Solicitar cliente','Solicitar DEV')"
    }
  ]
}
  • it would have worked with converting also....not sure if you have checked my answer... – Siddharth Vaghasia Jul 18 '19 at 18:03
  • Hello Siddharth, I checked your answer. But that didn't work, as a Date column always have a default value as it is a Struct. Converting it to String removes this. – Lucas Sousa Jul 23 '19 at 0:01
  • Not sure...but it worked for my tenant...that's fine...please upvote if it was helpful... – Siddharth Vaghasia Jul 23 '19 at 4:00

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.