0

I am trying to us column formatting in SharePoint Online and am very new to JSON. I am trying to use conditional formatting based on another column. This was the code I was using when we could do calculated columns.

I would really appreciate anyones help getting me started on how to do this.

=IF(CAI=”Green”,””&[CAI Vendors]&””,IF(CAI=”Yellow”,””&[CAI Vendors]&””,IF(CAI=”Red”,””&[CAI Vendors]&””,””)))

2

Microsoft block the execution of custom markup in calculated fields in SharePoint Online from June 13, 2017 onwards.

You can use the JSON to format the “CAI Vendors” column. Enter the following JSON to the “CAI Vendors” column.

{

   "elmType": "div",
   "txtContent": "@currentField",
   "style": {
      "color": {
         "operator": "?",
         "operands": [
            {
               "operator": "==",
               "operands": [
                  "[$CAI]",
                  "Red"
               ]
            },
            "#ff0000",
            {
         "operator": "?",
         "operands": [
            {
               "operator": "==",
               "operands": [
                  "[$CAI]",
                  "Green"
               ]
            },
            "#00ff00",
            {
         "operator": "?",
         "operands": [
            {
               "operator": "==",
               "operands": [
                  "[$CAI]",
                  "Yellow"
               ]
            },
            "#ffff00",
            ""
         ]
      }
         ]
      }
         ]
      }
   }
}

Information about column formatting with JSON in SharePoint Online.

  • I am not sure I am following what you are asking me to do? I have a status field that is what is used for the color change in the vendor field. I dont see where I am supposed to reference that other column. I am so new to JSON i am sorry if the answer is simple. – Dorinda May 15 '18 at 15:53
  • Ok I got this to partially work. However, it only works when the column that it is pulling the information from [$CAI] is also included in the view. I dont want the addtional columns in the view, Is there away for this to work with out them? – Dorinda May 15 '18 at 20:27
  • 1
    Currently, it is impossible. Is the status "CAI" based on other columns? You can directly use json to check whether it is red/yellow/green based on other columns instead of using a "CAI" column. – JoannaW_MSFT May 16 '18 at 1:36

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.