Why won't my JSON work for column formatting to color code the events calendar on my MS Teams SharePoint site?

Mallory 0 Reputation points
2024-10-18T18:11:49.1366667+00:00

I would like to color code the calendar events based on choices for the “Source” category column, and I understand you can do this by going into List Settings<(Column name) <Column Formatting. I used chatGBT to create a JSON, but for some reason my events are still all black. I've included the JSON below. All the other column formatting questions that I have seen online look much different, so I've also attached a screenshot of the “Edit column” page for the column I would like to add conditional formatting to change the color of the event boxes.

 

{ "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json", "elmType": "div", "style": { "background-color": "=if(@currentField == 'Enterprise Forums', '#F5A623', if(@currentField == 'G&G Routines', '#4A90E2', if(@currentField == 'Finance/HR', '#50E3C2', if(@currentField == 'Strategy', '#B8E986', '#FFFFFF'))))", "color": "#000000", "padding": "5px" }, "children": [ { "elmType": "span", "txtContent": "@currentField" } ] }

Image

Microsoft 365 and Office | SharePoint | Development
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AllenXu-MSFT 24,951 Reputation points Moderator
    2024-10-21T02:56:27.2866667+00:00

    Hi @Mallory,

    JSON column formatting only works under standard list view like below, it doesn't work for calendar view.

    User's image

    You can create rules for the calendar view via "Format current view" to color the event boxes. Reference: How to format a Microsoft Lists Calendar view.

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.