JSON sometimes is not applied to List view and forms

Mark Johnston 21 Reputation points
2022-08-16T20:48:49.487+00:00

I created a SharePoint online list and created a calendar view. I added JSON for the calendar view. The formatting works as expected, but sometimes it doesn't shown up at all on the calendar view. If I close the page, clear the browser cache, and reload the page it usually works the first time. I created the list to be viewed via Teams and the JSON isn't applied there. Looking at the browser debugger when the JSON is not applied, I see many errors that look like this " ProgramStatus was not found on the data object." with all the internal names listed. These errors do not occur when the JSON works. I have tried the latest versions of Edge and Firefox. Once this occurs, it seems to affect the other tabs in the same browser and perhaps even other instances in other browsers or Teams. And it can occur on a simple page refresh.

The list content type read only is set to No.

This is what it should look like:
231734-image.png

But this is what happens:
231650-image.png

This feels like some sort of authentication issue as the data is not being loaded properly some of the time. I even, just for old-times sake, made the website a trusted site. This had no affect.

Microsoft 365 and Office SharePoint For business Windows
{count} votes

Accepted answer
  1. Yanli Jiang - MSFT 31,596 Reputation points Microsoft External Staff
    2022-08-19T02:30:42.267+00:00

    Hi @Mark Johnston ,
    Great to know that and thanks for sharing the update here.

    By the way, since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others.". and according to the scenario introduced here: Answering your own questions on Microsoft Q&A, I would make a brief summary of this thread:

    [JSON sometimes is not applied to List view and forms]

    Issue Symptom:
    I created a SharePoint online list and created a calendar view. I added JSON for the calendar view. The formatting works as expected, but sometimes it doesn't shown up at all on the calendar view. If I close the page, clear the browser cache, and reload the page it usually works the first time. I created the list to be viewed via Teams and the JSON isn't applied there. Looking at the browser debugger when the JSON is not applied, I see many errors that look like this " ProgramStatus was not found on the data object." with all the internal names listed. These errors do not occur when the JSON works. I have tried the latest versions of Edge and Firefox. Once this occurs, it seems to affect the other tabs in the same browser and perhaps even other instances in other browsers or Teams. And it can occur on a simple page refresh.

    The list content type read only is set to No.

    Current status:
    This answer totally fixed it, and it makes sense.

    Thanks for the answer from @shagra-ms on thread https://github.com/SharePoint/sp-dev-docs/issues/8373

    Error on switching to a Calendar View in the List Web Part

    Formatting is not applied if the Field is not in View.
    1 - I have a local repro, and I'll look into this.
    2 - Formatting wouldn't automatically include the fields used in the JSON in the ViewFields. In order for this to work, I would recommend to go to classic view settings, and include the fields used in the formatter JSON in the ViewFields. This will fix the issue you are facing.
    232363-image.png

    You could click the "Accept Answer" button for this summary to make it easier for other community member's to see the useful information when reading this thread.
    Thanks for your understanding!


2 additional answers

Sort by: Most helpful
  1. Mark Johnston 21 Reputation points
    2022-08-17T11:14:09.617+00:00

    Recreated the issue on a separate site (and computer, etc.). When using the default Title field/column in the JSON calendar view formatting, everything works as expected. Switching this to a choice field/column, recreates this problem.

    This JSON works:

    {  
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/calendar-formatting.schema.json",  
      "additionalEventClass": "=if([$Title] =='AAA', 'sp-css-color-WhiteFont sp-css-backgroundColor-BgBlue' , '')"  
    }  
    

    This JSON exhibits the issues of losing the formatting that is properly shown only after switching views:

    {  
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/calendar-formatting.schema.json",  
      "additionalEventClass": "=if([$Category] =='Blue', 'sp-css-color-WhiteFont sp-css-backgroundColor-BgBlue' , '')"  
    }  
    

  2. Mark Johnston 21 Reputation points
    2022-08-18T10:40:30.643+00:00

    This answer totally fixed it, and it makes sense.

    From @shagra-ms on thread https://github.com/SharePoint/sp-dev-docs/issues/8373

    Error on switching to a Calendar View in the List Web Part

    Formatting is not applied if the Field is not in View.
    1 - I have a local repro, and I'll look into this.
    2 - Formatting wouldn't automatically include the fields used in the JSON in the ViewFields. In order for this to work, I would recommend to go to classic view settings, and include the fields used in the formatter JSON in the ViewFields. This will fix the issue you are facing.

    232363-image.png

    Apart from this, would like to know the issues in which the Calendar as default view doesn't work for you. Would like to address those issues too, if you can share more details. Thanks :)

    0 comments No comments

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.