Hi,
Please have a try with the JSON below, it works in my end.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"attributes": {
"class": "=if(@currentField <=@now ,'sp-field-severity--severeWarning',if(@currentField <=(@now+7776000000) ,'sp-field-severity--warning','sp-field-severity--good'))"
},
"children": [
{
"elmType": "span",
"style": {
"display": "inline-block",
"padding": "0 4px"
},
"attributes": {
"iconName": "=if(@currentField <=@now ,'ErrorBadge',if(@currentField <=(@now+7776000000) ,'Error','Forward'))"
}
},
{
"elmType": "span",
"txtContent": "@currentField"
}
]
}
Update :
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": "=if(@currentField <=@now ,'#ff0000',if(@currentField <=(@now+7776000000) ,'#F4D03F','#58FF33'))"
}
}
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if(@currentField <=@now ,'#ff0000',if(@currentField <=(@now+7776000000) ,'#F4D03F','#58FF33'))"
}
}
If the answer is helpful, please click Accept Answer and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hi, @needhelpwithJSON ,
I updated with new JSON, choose the one you need.
Hi, @needhelpwithJSON ,
Have you tried with the new JSON? Does it work for you?
Dear Jerry Xu-MSFT,
Yes the second version is the one I used and changed the yellow and green only the red I couldn't figure out how but that is due to a lack of knowledge on my part.
the JSON I used ↓ {
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if(@currentField <=@now ,'#ff0000',if(@currentField <=(@now +7776000000) ,'#96882b','#458b50'))"
}
THANK YOU for your help
Hi, @needhelpwithJSON ,
Do you want to use another color instead of red? Just change the '#ff0000' to something you like.
As the reply helps you, please accept it as answer. It will help other community members with similar question.
Good Afternoon Jerry Xu-MSFT,
i have been using this JSON which you helped with and it has been working great the only issue being the background colour when the field is empty.
can you assist how do I change it that when they expire its red 90 days before expiry yellow, green when it's not in 90 days before expiry and background colour when there is no date input.
Any help would be appreciated.
Thank you.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if(@currentField <=@now ,'#f53337',if(@currentField <=(@now +7776000000) ,'#96882b','#458b50'))"
}
}
Sign in to comment