SOLVED

List conditional formatting with multiple conditions and column references

Copper Contributor

list.jpgI used the interface to create the first condition on each column to highlight required information, logic for which is the following:

 

If Expired = Y, then Expired Explanation turns orange (required). If 'Other...' is chosen in Expired Explanation, then the Comments field turns orange.

 

I wish to add (via JSON I believe is the only way, since I can't find any OR options in the 'wizard') to this the following conditions:
If Expired = Y, then Expired Explanation turns orange (required). Then, when Expired Explanation is completed (a choice is selected), it turns pale green. If 'Other...' or 'Renewed' is chosen in Expired Explanation, then the Comments field turns orange. Then, when Comments is completed, it turns pale green.

I have searched and read and experimented but I am having a hard time understanding JSON syntax especially when I compare examples to the code that the 'wizard' is generating for the orange effect.

Many thanks for your help. I will have two more sets of these three-column contingencies when complete. (I tried validations first, but after several days abandoned that! I could only get one validation in one of the nine columns to work. :( )


2 Replies
best response confirmed by TanyaMc (Copper Contributor)
Solution

@TanyaMc yes you can do this and the result is shown below:

 

0-SP-list.png

 

For the Explanation column the JSON  that you need to paste into the Advanced mode window is as follows:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "padding-left": "14px",
    "background-color": "=if(@currentField == '' && [$Expired] == 'Y', '#ff7e00', if(@currentField != '' ,'#85b18e', '#cacfd6')",
    "color": "white"
  }
}

 

For the Comments column the JSON is:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "padding-left": "14px",
    "background-color": "=if(@currentField != '', '#85b18e', if(([$Explanation] == 'Other (provide comments)' || ([$Explanation] == 'Renewed'),'#ff7e00', '#cacfd6' )",
    "color": "white"
  }
}

 

Hope that helps.

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User.
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

 

1 best response

Accepted Solutions
best response confirmed by TanyaMc (Copper Contributor)
Solution

@TanyaMc yes you can do this and the result is shown below:

 

0-SP-list.png

 

For the Explanation column the JSON  that you need to paste into the Advanced mode window is as follows:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "padding-left": "14px",
    "background-color": "=if(@currentField == '' && [$Expired] == 'Y', '#ff7e00', if(@currentField != '' ,'#85b18e', '#cacfd6')",
    "color": "white"
  }
}

 

For the Comments column the JSON is:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "padding-left": "14px",
    "background-color": "=if(@currentField != '', '#85b18e', if(([$Explanation] == 'Other (provide comments)' || ([$Explanation] == 'Renewed'),'#ff7e00', '#cacfd6' )",
    "color": "white"
  }
}

 

Hope that helps.

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User.
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

 

View solution in original post