1

I am trying to use JSON to format a "Person" column in a Sharepoint list with an email action button.

I would like the email to contain a link to the Sharepoint list item in question, but the link contains ampersands (&).

Unfortunately the ampersand is a special character and chops the string after the 1st ampersand (as described here). Is there a way to stop this by getting the & to be treated as a symbol rather than a special character?

  • email action button - do you mean <a> with mailto:? – Sergei Sergeev Jan 17 at 9:26
1

You could try using URL encoding (percent encoding), replacing the & with %26. You can find all encoded characters on W3C.

1

You should encode only the body of your message. Use this service to build your url. Fill in required fields and then copy the value of href attribute from standard link from Output section (NOT encoded one).

For example below formatting works well for me (I use current item ID to build the url):

{
  "schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
    "elmType": "a",
    "attributes": {
      "target": "_blank",
      "href": "='mailto:some@user.com?subject=Hello&body=https%3A//myurl.com%3Fparam1%3D1%26param2%3D2%26ID%3D' + [$ID] + '\n another text'"
    },
    "txtContent": "[$Title]"
} 
1

You can replace & with %26 code in mailto:

you can refer below code

<p> This is an email link: <a href="mailto:someone@example.com?Subject=Hello%20again&body=Test%26Test" target="_top">Send Mail</a> </p>

More details about URL Encoding you can refer This

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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