Share via

Error in JSON formating

Ladislav Zelinka 51 Reputation points
Jan 13, 2023, 7:41 AM

Hi.

I want to use formatting in Sharepoint via JSON:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "debugMode": true,
  "txtContent": "@currentField",
  "style": {
    "color": "=if(@currentField<=@now, '#ff0000', ' ')"
  }
}

The result is:

Failure: The value of style =if(@currentField<=@now, '#ff0000', ' ') contains at least one of these illegal characters: ( : & ; ! .

Something is wrong when I can't insert ( in JSON

Thanks

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
11,230 questions
{count} votes

Accepted answer
  1. Renjie Sun-MSFT 2,861 Reputation points Microsoft Employee
    Jan 16, 2023, 2:09 AM

    Hi Ladislav Zelinka

    Thanks for the post.

    According to the tests, it works as expectation using your json code.

    The testing column is 'Date' column.

    The following is my testing result: The testing date is 1/16/2023

    image

    Please confirm that your input method is in English.


    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.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Ladislav Zelinka 51 Reputation points
    Jan 16, 2023, 7:33 AM

    Thanks for testing. I found myself having to use this format for if

    {"operator": "?", "operands": [{"operator": "==","operands": ["@currentField", ""]},"Yes","No"]}

    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.