1

I can't get SharePoint Online to recognize my field name. I know I could use @currentfield where I have [$2021_Q3] but I want to create a more complex formula and can't even get this basic one to work. Below is also the error I receive on the field

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "debugMode": true,
        "style":{
        "padding-left":"4px",
        "border-left-style": "solid",
        "border-left-width":"5px",
         "border-left-color":"=if([$2021_Q3]=='0','red','green')"
    },
    "attributes": {
        "class":"=if(@currentField==0,'sp-field-severity--severeWarning',if(@currentField==0,'sp-field-severity--warning','sp-field-severity--good'))"
    },
    "children": [
        {
            "elmType": "span",
            "attributes": {
                "iconName":"SortUp"
            }
        },
        {
            "elmType": "span",
            "txtContent":"@currentField"
        }
    ]
}

enter image description here

1 Answer 1

0

Fields must be referenced by their internal names. That is probably not the internal name of the 2021_Q3 column. If you entered it exactly like that the internal name is probably _x0032_021_Q3 so you would reference it in your format like this:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "debugMode": true,
        "style":{
        "padding-left":"4px",
        "border-left-style": "solid",
        "border-left-width":"5px",
         "border-left-color":"=if([$_x0032_021_Q3]=='0','red','green')"
    },
    "attributes": {
        "class":"=if(@currentField==0,'sp-field-severity--severeWarning',if(@currentField==0,'sp-field-severity--warning','sp-field-severity--good'))"
    },
    "children": [
        {
            "elmType": "span",
            "attributes": {
                "iconName":"SortUp"
            }
        },
        {
            "elmType": "span",
            "txtContent":"@currentField"
        }
    ]
}

If that doesn't work, you can check your internal field name by going to List Settings and clicking on the column. In the URL the field will be listed at the end. Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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