我有一个带有日历视图的SharePoint列表,其中的日期基于标题为ExpirationDate的列.

我想配置日历视图,以使今天到7天后到期日期的项目具有红色背景 colored颜色 .不幸的是,条件格式选项只有一个相对日期,那就是今天.我try 使用条件格式选项来获取基本代码并进行修改,但当我将7天后的静态日期替换为"@NOW+604800000"时,它无法识别该日期.

另外,出于某种原因,我的ExpirationDate列被引用为[$Expation_x0020_Date]--我只能假设这是因为标题中最初有一个空格.

SP生成的代码:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "additionalEventClass": {
    "operator": ":",
    "operands": [
      {
        "operator": "&&",
        "operands": [
          {
            "operator": ">=",
            "operands": [
              {
                "operator": "Date()",
                "operands": [
                  {
                    "operator": "toDateString()",
                    "operands": [
                      {
                        "operator": "Date()",
                        "operands": [
                          "[$Expiration_x0020_Date]"
                        ]
                      }
                    ]
                  }
                ]
              },
              {
                "operator": "Date()",
                "operands": [
                  {
                    "operator": "toDateString()",
                    "operands": [
                      {
                        "operator": "Date()",
                        "operands": [
                          "@now"
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "operator": "<=",
            "operands": [
              {
                "operator": "Date()",
                "operands": [
                  {
                    "operator": "toDateString()",
                    "operands": [
                      {
                        "operator": "Date()",
                        "operands": [
                          "[$Expiration_x0020_Date]"
                        ]
                      }
                    ]
                  }
                ]
              },
              {
                "operator": "Date()",
                "operands": [
                  {
                    "operator": "toDateString()",
                    "operands": [
                      {
                        "operator": "Date()",
                        "operands": [
                          "Thu Sep 14 2023"
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      },
      "=if(@isSelected == true, 'sp-css-color-WhiteFont sp-css-backgroundColor-BgDarkRed' , 'sp-css-backgroundColor-BgCoral sp-css-color-CoralFont')",
      ""
    ]
  }
}

就像我说的,试图用一个相对的日期来划分指定的日期,没有骰子.

推荐答案

try 对您的SharePoint Online现代列表日历视图使用如下所示的JSON格式代码:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "additionalEventClass": "=if([$Expiration_x0020_Date] >= @now && [$Expiration_x0020_Date] <= addDays(@now, 7), if(@isSelected == true, 'sp-css-color-WhiteFont sp-css-backgroundColor-BgRed', 'sp-css-backgroundColor-BgDustRose sp-css-color-DustRoseFont')+' sp-field-fontSizeSmall', if(@isSelected == true, 'sp-css-color-WhiteFont sp-css-backgroundColor-BgGray' , 'sp-css-backgroundColor-BgLightGray sp-css-color-LightGrayFont')+' sp-field-fontSizeSmall')"
}

其中,Expiration_x0020_Date是您的SharePoint列表列的内部名称.您可以通过遵循本文获得您的SharePoint列表列的内部名称:How to find the Internal name of columns in SharePoint Online?

Related Reference:SharePoint: Highlight selected list item rows using JSON formatting-@isSelected

Json相关问答推荐

Elasticsearch Go客户端错误:无效的SON格式:在中间件中索引文档时出错

使用Jolt将字符串数组转换为JSON对象数组

如何在JQ过滤器文件中使用多行?

Vega图表计数聚合如果数据值为空数组则不显示任何内容,如何解决此问题?

使用Jolt v.0.1.1向每个json元素添加一个键-值对

nlohmann json:为什么我会得到一个解析错误?

将 REST API - json 输出转换为表 Power BI

Rust实现:高效解析任意大小的JSON数组

匹配来自不同数组的值

Groovy JsonBuilder 在for循环中添加数组元素

通过 xslt 将内部 json 转换为 xml 时遇到问题

如何在 Go 中生成带有排序键的 JSON?

反序列化大型 json 对象的 JsonMaxLength 异常

jQuery fullcalendar 发送自定义参数并使用 JSON 刷新日历

在 Webpack 中加载静态 JSON 文件

使用 JSON.Net 的 C# 到 JSON 序列化

如何判断 JSON 响应元素是否为数组?

将 json 转换为 C# 数组?

杰克逊在通用列表中读取 json

XML vs YAML vs JSON