JSON Formatting

Home Page Forums Office 365 SharePoint JSON Formatting

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  Charmian A 3 months, 3 weeks ago.

  • Author
    Posts
  • #822

    Martin Hulme
    Participant

    Hi There.

    I’m new to the group today, so thank you for adding me.

    I am trying to use JSON to colour code fields in a Sharepoint List.

    I am not a programmer and have managed to put together a script that partially works, but I am stumped as to how to make it all work.

    I am just looking at the content of a single field for a known string, if it matches then the field box turns the colour defined in the code.

    In the code below, the first 4 operands work but the last one does NOT.
    I have checked the formatting a validated the JSON with availible online tools but for some reason it stops colour coding the fields after the 4th one.

    Any help appreciated.

    {
    “$schema”: “http://columnformatting.sharepointpnp.com/columnFormattingSchema.json”,
    “debugMode”: true,
    “elmType”: “div”,
    “txtContent”: “@currentField”,
    “style”: {
    “color”: “#111”,
    “padding-left”: “14px”,
    “background-color”: {
    “operator”: “?”,
    “operands”: [
    {
    “operator”: “==”,
    “operands”: [
    “@currentField”,
    “PARKED”
    ]
    },
    “#e81123”,

    {
    “operator”: “?”,
    “operands”: [
    {
    “operator”: “==”,
    “operands”: [
    “@currentField”,
    “ONGOING”
    ]
    },
    “#00B294”,
    {
    “operator”: “?”,
    “operands”: [
    {
    “operator”: “==”,
    “operands”: [
    “@currentField”,
    “COMPLETED”
    ]
    },
    “#ff8c00”,
    {
    “operator”: “?”,
    “operands”: [
    {
    “operator”: “==”,
    “operands”: [
    “@currentField”,
    “Chased Client”
    ]
    },
    “#fff100”,
    {
    “operator”: “?”,
    “operands”: [
    {
    “operator”: “==”,
    “operands”: [
    “@currentField”,
    “ISIS MEDIA DELETED”
    ]
    },
    “ab12cd”,
    “”
    ]
    }
    ]
    }
    ]
    }
    ]
    }
    ]
    }
    }
    }

  • #885

    Charmian A
    Participant

    Hi Martin
    I’m not a programmer either but have been trying to work with JSON myself.
    I’ve found this resource helpful: https://jsonlint.com/
    You’ve probably resolved this by now but perhaps it was this “ab12cd”, which was the issue? If it’s a colour code, shouldn’t it begin with a #?

You must be logged in to reply to this topic.