0

I am in a position where all I want to do is change the font color of a column to #002c77 no matter what the text within the text field says. I cannot for the life of me get it to work, and there I am sure I am doing something wrong.

until now I have it like this and it does not work

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "color": "=if([$Stadie] == 'Stadie 1 - Påbegyndt', '#002c77',
    if([$Stadie] == 'Stadie 2 - Påbegyndt', '#002c77', 
    if([$Stadie] == 'Stadie 3 - Påbegyndt', '#002c77', 
    if([$Stadie] == 'Stadie 4 - Påbegyndt', '#002c77', 
    if([$Stadie] == 'Completed', '#002c77')))))"
  }    
}

And previously I tried this:

{
   "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
   "elmType": "div",
   "txtContent": "@currentField", 
   "style":{
     "color":{
       "operator": "?",
       "operands": [
         {
           "operator": "==",
           "operands": [
             "@currentField", "Stadie 1 - Påbegyndt",
             {
               "operator": "==",
               "operands": [
                 "@currentField", "Stadie 2 - Påbegyndt"
               ]
             },
             "#002c77",
             ""
          ] 
         },
         "#002c77",
         ""
       ]
     }
   }
}

But it only seemed to work with the first one and not the ones after, anyone know how to format the text within a field no matter what it says so that the font color is changed to #002c77?

Thanks in advance.

  • What is the data type of your field/column? – Ganesh Sanap Nov 20 '19 at 9:05
0

Try using below JSON Code:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "color": "#002c77"
  }
}

Official documentation: Use column formatting to customize SharePoint.

Output:

enter image description here

| improve this answer | |
  • 1
    That did the trick, thanks! :) – TobiNNC Nov 20 '19 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.