Question

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')"
    }
  ]
}
Was it helpful?

Solution 2

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')"
    }
  ]
}

OTHER TIPS

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')"
    }
  ]
}
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top