1

I have the following problem. I have a SharePoint online list for which I have customized the form with JSON. I added an email button which allows the user of the form to open a predefined email with Information deriving from the form.

My problem is that I would like to add a link into the email directly referring to the form so that the receiver of the email can directly reach out to the form to add further input.

Is this possible with JSON code? Unfortunately I am not allowed to use the power platform. Thank you in advance.

3
  • Are you using mailto button in JSON formatting? Commented Jun 8, 2023 at 8:37
  • Yes Iam using the mailto button
    – Jan
    Commented Jun 8, 2023 at 11:41
  • check my answer below. Commented Jun 8, 2023 at 11:56

2 Answers 2

1

Usually, the link to SharePoint list item display form is in this format:

https://contoso.sharepoint.com/sites/siteName/Lists/listName/DispForm.aspx?ID=1

Where 1 is the list item ID (SharePoint default column).

But unfortunately, SharePoint JSON form formatting does not support fetching item ID ([$ID]) currently as we can use it in column/view formatting.

Reference: Can ID column be displayed when configuring a list form header using JSON?

So, you will not be able to add link to list item form using JSON formatting using SharePoint out of the box capabilities.


Additional:

You can create send an email link using JSON formatting. Example:

{
  "elmType": "div",
  "style": {
    "width": "100%",
    "display": "=if([$Title] && [$AssignedTo.email], 'block', 'none')",
    "padding-top": "10px",
    "border-top": "1px solid"
  },
  "attributes": {
    "class": "ms-fontColor-neutralSecondary"
  },
  "children": [
    {
      "elmType": "a",
      "attributes": {
        "target": "_blank",
        "href": {
          "operator": "+",
          "operands": [
            "mailto:",
            "[$AssignedTo.email]",
            "?subject=Task status&body=Hey, how is your task (",
            "[$Title]",
            ") coming along?"
          ]
        },
        "class": "ms-fontColor-themePrimary"
      },
      "children": [
        {
          "elmType": "span",
          "txtContent": "Send Email to Task Owner"
        },
        {
          "elmType": "span",
          "style": {
            "margin-left": "8px",
            "vertical-align": "middle"
          },
          "attributes": {
            "iconName": "OutlookLogo",
            "class": "ms-fontColor-themePrimary ms-fontSize-xl"
          }
        }
      ]
    }
  ]
}

Where AssignedTo is the internal name of person or group column in the list. You can get the internal name of your column by following this article: How to find the Internal name of columns in SharePoint Online?

Output:

enter image description here


It is not possible to add HTML/hyperlinks in email body using mailto as it does not support using HTML in email body.

References:

  1. JSON formatting: make some words inside body text of email bold
  2. How do I pass HTML table inside mailto in anchor tag?
5
  • One workaround I can see is: Create a text/hyperlink column in your list. Then create a simple designer 2013 workflow (or power automate flow if you can use) which will run on item creation and update the newly created column with URL in format mentioned in above answer. Then you can use the item URL in your JSON. Commented Jun 8, 2023 at 11:59
  • Thanks Ganesh for the detailed answer. Unfortunately I am neither allowed to use power automate nor designer. However, to solve the issue I did a simple non-coding workaround: I created an additional single line text column and created a reservoir of dozens of empty list entries. I simply copied for each entry the assinged ID to the single line text ID field. With that it is possible to refer dynamically to the "copied" ID number and I used this in the "mailto" json. Thanks again
    – Jan
    Commented Jun 11, 2023 at 11:25
  • Ok great, that works too. But, it is a manual work every time someone creates a new item in the list. You will have to copy the item ID to new field after new item creation. Commented Jun 11, 2023 at 12:07
  • Hi @Jan, does this answer help you in any way? Commented Jun 12, 2023 at 3:16
  • Hi Ganesh, yes it definitely helped me since I was not sure if there is really no chance to do it in json. I uprated and accepted your answer. Thank you
    – Jan
    Commented Jun 12, 2023 at 6:16
0

I am new to JSON and I also cannot use Power suite nor Designer. The workaround I used to obtain the ID, is by creating a calculated column in the List named "RecID" (you can name it as you wish) and entered in it "=ID". That allowed me to use RecID in my JSON code to obtain the current ID. I hp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.