$RenewalDate 的第一个示例
试试这个三元 (?) 运算符代码
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": {
"operator": "?",
"operands": [
{
"operator": "<=",
"operands": [
"[$RenewalDate]",
{
"operator": "+",
"operands": [
"@now",
-2678400000
]
}
]
},
"#ff0000",
""
]
}
}
}
第二个例子是名称中带有空格的列$Renewal_x0020_Date
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": {
"operator": "?",
"operands": [
{
"operator": "<=",
"operands": [
"[$Renewal_x0020_Date]",
{
"operator": "+",
"operands": [
"@now",
-2678400000
]
}
]
},
"#ff0000",
""
]
}
}
}
编辑:
使用 Excel 样式的表达式语法
没有空格的列$RenewalDate
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": "=if([$RenewalDate] <= @now - 2678400000, '#ff0000', '')"
}
}
带空格的列$Renewal_x0020_Date
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": "=if([$Renewal_x0020_Date] <= @now - 2678400000, '#ff0000', '')"
}
}