用于添加超链接的 JSON 列格式在最近的 Microsoft 列表更新后被破坏 - 仅影响 ?env=WebViewList 视图

问题描述 投票:0回答:1

之前,我们通过 JSON 列格式在“单行文本”列中创建了链接。

此基本功能记录在此处:

https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting#turn-field-values-into-hyperlinks-basic

他们提供的例子是:

{
   "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
   "elmType": "a",
   "txtContent": "@currentField",
   "attributes": {
      "target": "_blank",
      "href": "='http://finance.yahoo.com/quote/' + @currentField"
   }
}

因此,没有动态内容的简单示例是:

{
   "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
   "elmType": "a",
   "txtContent": "TEST",
   "attributes": {
      "target": "_blank",
      "href": "https://google.com"
   }
}

Microsoft 最近推出 Microsoft 列表更新后,记录如下:

https://techcommunity.microsoft.com/t5/microsoft-365-blog/microsoft-lists-easier-better-faster-stronger/ba-p/3806075

单击我们的 JSON 列格式生成的链接不会打开链接。

当我们点击链接时,没有任何反应。

为了澄清,上面提供的示例确实有效,但过去对我们有用的自定义 JSON 列格式不再有效。

如果我们从列表 URL 中删除

?env=WebViewList
后缀,链接就会起作用。

我们租户中所有列表中的所有网站都发生这种不良行为。

重现步骤

01) 创建 Microsoft 列表

02) 转到列表并确保其具有后缀

?env=WebViewList

(以便它以现代的“微软列表”外观显示),例如:

https://<your-tenant>.sharepoint.com/sites/<your-site>/Lists/<your-list>/AllItems.aspx?env=WebViewList

(注意:此问题可以在个人 Microsoft 列表和存储在 SharePoint 站点中的列表中重现)。

03) 在类型为“单行文本”的列表中创建一个列。

04) 单击列标题并选择

Column Settings
>
Format this column
>
Advanced mode

05) 粘贴以下代码并点击保存

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "attributes": {
    "href": "https://www.google.com",
    "target": "_blank"
  },
  "style": {
    "text-decoration": "none"
  },
  "children": [
    {
      "elmType": "button",
      "attributes": {
        "class": "ms-fontColor-themePrimary ms-fontColor-themeDark--hover",
        "title": "Click Me"
      },
      "style": {
        "border": "none",
        "background-color": "transparent",
        "cursor": "pointer"
      },
      "children": [
        {
          "elmType": "span",
          "attributes": {
            "iconName": "Attach",
            "class": "ms-font"
          },
          "style": {
            "padding-right": "2px"
          }
        },
        {
          "elmType": "span",
          "txtContent": "Click Me"
        }
      ]
    }
  ]
}

06) 将项目添加到列表中,以便您可以看到生成的链接

07) 点击生成的链接,什么也不会发生

08)(如果您正在 SharePoint 网站内的列表上进行测试,请从列表 URL 中删除

?env=WebViewList
并重新加载列表,链接将起作用)。

更新:

经过进一步调查,如果我单击链接文本的右侧,该链接会起作用,但如果我单击链接文本本身,该链接将不起作用。

sharepoint-online sharepoint-list
1个回答
0
投票

有关于这个问题的消息吗? 当我们得到新的列表体验后,我们有相同的。

© www.soinside.com 2019 - 2024. All rights reserved.