Error in JSON formating

Ladislav Zelinka 51 Reputation points
2023-01-13T07:41:44.7733333+00:00

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

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

Answer accepted by question author
  1. Renjie Sun-MSFT 2,861 Reputation points Microsoft Employee
    2023-01-16T02:09:26.9133333+00:00

    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
    2023-01-16T07:33:48.79+00:00

    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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.