【问题标题】:How to include blank spaces " " in a hyperlink in JSON when formatting a SharePoint List Column格式化 SharePoint 列表列时如何在 JSON 的超链接中包含空格“”
【发布时间】:2019-06-09 13:05:50
【问题描述】:

我正在尝试使用 JSON 格式在电子邮件中包含指向特定 SharePoint 列表项的链接,但 URL 包含空格,我似乎无法将其包含在超链接中。

我尝试使用 "%20" 以及 "x0020" 代替空格, 但这只是读作空格。

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
    "elmType": "div",
    "children": [
        {
            "elmType": "span",
            "style": {
                "padding-right": "8px"
            },
            "txtContent": "@currentField.title"
        },
        {
            "elmType": "a",
            "attributes": {
                "iconName": "Mail",
                "class": "sp-field-quickActions",
                "href": {
                    "operator": "+",
                    "operands": [
                        "mailto:",
                        "@currentField.email",
                        "?subject=Task status&body=Hi ","@currentField.title",", Please see below link to a Shared Services Team Task which requires your attention.\r\n\r\n---\r\n",
                        "\r\nClick this link for more info. https://MyCompany.sharepoint.com/sites/SharedServicesDepartment/Lists/Task Management Register/DispForm.aspx?ID=",
                        "[$ID]"
                    ]
                }
            }
        }
    ]
}

我想要实现的是一个超链接

https://MyCompany.sharepoint.com/sites/SharedServicesDepartment/Lists/Task Management Register/DispForm.aspx?ID=

但它会在第一个空格处切断超链接,并将最后一部分保留为文本。

https://MyCompany.sharepoint.com/sites/SharedServicesDepartment/Lists/Task 管理寄存器/DispForm.aspx?ID=

【问题讨论】:

  • JSON 是如何生成的?如果是通过程序,请分享您尝​​试过的方法来解决您的问题。

标签: json sharepoint


【解决方案1】:

我们可以使用下面的JSON格式来实现。

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
    "elmType": "div",
    "children": [
        {
            "elmType": "span",
            "style": {
                "padding-right": "8px"
            },
            "txtContent": "@currentField.title"
        },
        {
            "elmType": "a",
            "attributes": {
                "iconName": "Mail",
                "class": "sp-field-quickActions",
                "href": {
                    "operator": "+",
                    "operands": [
                        "mailto:",
                        "@currentField.email",
                        "?subject=Task status&body=Hi ","@currentField.title",", Please see below link to a Shared Services Team Task which requires your attention.\r\n\r\n---\r\n",
                        "\r\nClick this link for more info. <https://MyCompany.sharepoint.com/sites/SharedServicesDepartment/Lists/Task Management Register/DispForm.aspx?ID=",
                        "[$ID]",
                        ">"
                    ]
                }
            }
        }
    ]
}

参考:Add links containing spaces to an e-mail message

【讨论】:

  • 在 URL 的任一侧添加“”效果很好。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-16
  • 2018-06-12
  • 2020-03-23
相关资源
最近更新 更多