Forum Discussion
JSON if statement for conditional formatting
- Apr 09, 2021
JTFInc you need to use || which stands for or (&& is and) 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([$Position] == 'Chief Cook' || [$Position] =='Cook' || [$Position] == 'Steward' , '#00afff', '#d7dae1')", "color": "black" } }
I've used this JSON to format the Contract column in the image below:
Rob
Los Gallardos
Microsoft Power Automate Community Super User
JTFInc you need to use || which stands for or (&& is and) 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([$Position] == 'Chief Cook' || [$Position] =='Cook' || [$Position] == 'Steward' , '#00afff', '#d7dae1')",
"color": "black"
}
}
I've used this JSON to format the Contract column in the image below:
Rob
Los Gallardos
Microsoft Power Automate Community Super User
Hi RobElliott, hoping you can assist in a similar situation.
I've got a Sharepoint list with folders and excel files that either have a response due date or do not. I want a column field to be visible only if the list entity is an excel file with a listed response due date.
The below JSON has successfully hidden the field for folders, but my second conditional to hide the field if the 'Responses Due' column is blank is not working.