Microsoft sharepoint JSON formatting error in calculated column

Viewed 808

Why does the error mean? In trying to style a sharepoint list with column formatting with the follow code (taken from the documentation)?

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "attributes": {
    "class": "=if(@currentField < 7,'sp-field-severity--warning', '')"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 4px"
      },
      "attributes": {
        "iconName": "=if(@currentField <= 70,'Error', '')"
      }
    },
    {
      "elmType": "span",
      "txtContent": "@currentField"
    }
  ]
}

this is the error

Error saving column format:

{
   "d":{
      "CustomFormatter":"{\"$schema\":\"https:\u002F\u002Fdeveloper.microsoft.com\u002Fjson-schemas\u002Fsp\u002Fv2\u002Fcolumn-formatting.schema.json\",\"elmType\":\"div\",\"attributes\":{\"class\":\"=if(@currentField < 7,'sp-field-severity--warning', '')\"},\"children\":[{\"elmType\":\"span\",\"style\":{\"display\":\"inline-block\",\"padding\":\"0 4px\"},\"attributes\":{\"iconName\":\"=if(@currentField <= 70,'Error', '')\"}},{\"elmType\":\"span\",\"txtContent\":\"@currentField\"}]}",
      "Id":""
   }
}
1 Answers

antonioa7, Check the datatype of the column where you have applied this formatting (number expected). I tried it for the number field, and it worked, whereas I tried it for text column, and it showed the same error you have posted here.

Related