1

I've looked at various sources, tried various solutions but nothing seems to work for me. I'm using SP, I don't know which version but it's a later one - it has the option to click back to 'Classic Experience'.

I have a list, and I want to make the STATUS field with Assigned, Ongoing, and Complete change the full row color depending on which option is selected.

I've attached a screenshot of the only field I have which mentions Column formatting. This is all I can find that seems to have anything to do with JSON. I've put various formulas in there but at best, the option selected in the status field vanishes from view and it's just blank, at worst it gives me an error about illegal character entry.

Here are various examples I've tried:

{
  "schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "additionalRowClass": "=if([$Status] == 'Complete', 'sp-field-severity--good', if([$Status] == 'Ongoing', 'sp-field-severity--low' ,if([$Status] == 'Assigned', 'sp-field-severity--low' ,''))))"
}

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
    "elmType": "div",
    "style": {
        "color": "=if([$Status] != 'Complete' , 'red' , '')"
    },
    "txtContent": "@currentField"
}



{
  "schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "additionalRowClass": "=if([$Status] == 'Assigned', 'sp-field-severity--good', if([$Status] == 'Ongoing', 'sp-field-severity--low' ,if([$Status] == 'Complete','sp-field-severity--warning', ''))))"
}

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "debugMode": true,
  "txtContent": "@currentField",
  "style": {
    "color": "=if(@currentField == 'Assigned', '#008000', if([$Date] < @now , '#ff0000',if([$Date] > @now, '#FFFF00', '#00FF00')))"
  }
}




{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "attributes": {
    "class": "=if(@currentField == 'Assigned', 'sp-field-severity--good', if(@currentField == 'Ongoing', 'sp-field-severity--low', if(@currentField == 'Complete', 'sp-field-severity--warning')))) + ' ms-fontColor-neutralSecondary'"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 4px"
      },
      "attributes": {
        "iconName": "=if(@currentField == 'Assigned', 'CheckMark', if(@currentField == 'Ongoing', 'Forward', if(@currentField == 'Complete', 'Error'))))"
      }
    },
    {
      "elmType": "span",
      "txtContent": "@currentField"
    }
  ]

Edit: Sorry, don't know why I can't get the image to show. It's here:

enter image description here

0

For your requirements, you have to use the JSON View formatting in SharePoint.

Use below JSON:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
    "additionalRowClass": "=if([$Status] == 'Complete', 'sp-field-severity--good', if([$Status] == 'Ongoing', 'sp-field-severity--low', if([$Status] == 'Assigned', 'sp-field-severity--warning', '')))"
}

Where Status is internal name of your choice column. Check below article to find out the internal name of SharePoint column:

Find the internal name of SharePoint column

Make sure you are using correct internal name & adding the JSON at right place like below:

enter image description here

Documentation: Use view formatting to customize SharePoint


Update from comments:

View formatting is currently supported only in SharePoint Online and not in SharePoint 2019.

5
  • Hi, thanks Ganesh. I've seen your answers elsewhere and tried to get them to work but to no avail unfortunately. When I click 'All Items' in the list, the drop-down only shows me: Items that need attention All Items Save View As Edit Current View How would I activate or find this View Formatting? Thanks!
    – Cal
    Nov 24 at 7:07
  • Are you using custom list or any other list template? Also, do you see column formatting option for any column? If yes, you can open the json formatting pane using column formatting & then select "Format View" & "List" in Choose layout as shown in above image. Nov 24 at 7:13
  • Hi Ganesh. I'm using a custom list. I've also identified it's SP19 that we're using. I can't find a column formatting option. All I see is the conditional formatting box.
    – Cal
    Nov 25 at 7:18
  • Unfortunately, View formatting is currently supported only in SharePoint Online. So, you cannot use this in SP 2019. Nov 25 at 7:29
  • Thanks for your help Ganesh, sorry to have wasted your time.
    – Cal
    Nov 25 at 7:32

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.