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

0

The answer here is to use operators and operands instead of a + on a single line

{ "$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=Hey, how is your task coming along?.\r\n---\r\n", "@currentField.title", "\r\nClick this link for more info. http://contoso.sharepoint.com/sites/ConferencePrep/Tasks/Prep/DispForm.aspx?ID=", "[$ID]" ] } } } ] }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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