0

I have the following issue. I need a button in a list form which first of all opens a predefined email in outlook. As a second functionality at the same time a normal link (preferably in the same tap where the form is displayed) should open.

For the email I am using JSON mailto-scenario but I do not know how to add in addition the required link. Thanks in advance for any recommendation.

1 Answer 1

1

Extending my answer from Add button for email in list form footer using JSON. Email content must include link to the form,

You have to generate link in below format which will open list item display form:

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

As you mentioned in this comment, if you have created another list column where you copy the current list item ID, you can use JSON like below in footer layout form formatting for adding link to list item.

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?",
            "\r\nClick this link for more info: https://contoso.sharepoint.com/sites/siteName/Lists/listName/DispForm.aspx?ID=",
            "[$CustomID]"
          ]
        },
        "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"
          }
        }
      ]
    }
  ]
}

Assuming internal name of your new list column is CustomID.

Output:

List view:

enter image description here

List form:

enter image description here

Note:

  1. Depending on the email client application you are using (e.g. Outlook/Gmail), hyperlink can be clickable or not-clickable

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

Read more information at:

  1. JSON formatting: make some words inside body text of email bold
  2. How do I pass HTML table inside mailto in anchor tag?

Update from comments:

Unfortunately, you cannot multiple links on single hyperlink/button using SharePoint JSON formatting. You will have to create another hyperlink/button for redirecting users to web page / SharePoint web site.

3
  • Thanks for feedback but perhaps my question is missleading. I need two functions triggered with the same Button. First function is the email which include the link to the item itself. This is what we already successfully discussed. At the same time I need another function triggered with the same button to close the open form. But I think this is not possible. That is why I hope there is a way with JSON to trigger the tap with the open form being redirected to another sharepoint website. (The idea is to make the user clear that his/her to do's are done)
    – Jan
    Commented Jun 12, 2023 at 7:27
  • Unfortunately, you cannot do it using single hyperlink/button. You will have to create another hyperlink/button for redirecting it to web page. Let me know if you need any help with that. Commented Jun 12, 2023 at 7:38
  • 1
    Thanks for confirmation that this is not possible. How to create simple hyperlink button is clear to me. Thank you BR Jan.
    – Jan
    Commented Jun 12, 2023 at 9:33

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.