JSON-Code (multiple "$Attendees.email")

Martin, Heidi (SE GP T SP PS) 571 Reputation points
2023-08-08T05:33:39.2766667+00:00

Good morning,

I have a JSON-Code for a SharePoint column. The code works fine, but if there are multiple "[$Attendees.email]" then unfortunately this code stops working.

Tested with 6 "[$Attendees.email]" it worked fine. But I also have more than 6 "[$Attendees.email]", there it didn't work anymore.

Is it possible to customize the code so that many email recipients work?

Thank you!

This is the code snippet:

{
  "$schema": https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json,
  "elmType": "div",
  "children": [
    {
      "elmType": "span",
      "style": {
        "padding-right": "20px"
      },
      "txtContent": "@currentField.title"
    },
    {
      "elmType": "a",
      "attributes": {
        "iconName": "Mail",
        "class": "sp-field-quickActions",
        "href": {
          "operator": "+",
          "operands": [
            mailto:,
            "[$Attendees.email]",
            ?Bcc=XXX,
            "[$BCC]",
            "&subject= Event name: ",
            "[$Title]",
            " | Event date: ",
            "[$Startdate]",
            "&body=",
            "Dear XXX,",
            "\r\n \r\n",
....
Microsoft 365 and Office SharePoint For business Windows
{count} votes

Accepted answer
  1. Yanli Jiang - MSFT 31,596 Reputation points Microsoft External Staff
    2023-08-11T06:21:22.4933333+00:00

    Hi @Martin, Heidi (SE GP T SP PS) ,

    First of all, the Q&A forum is an open platform, please pay attention to protecting private information.

    According to my research and testing, there should be no such limitation. My tests have also proven this to be the case. Can you describe specifically how it behaves with more than 12 recipients?

    This is the JSON code I used for testing:

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "a",
      "style": {
        "display": "=if(length([$Atendees]) > 0, 'flex', 'none')",
        "text-decoration": "none"
      },
      "attributes": {
        "href": {
          "operator": "+",
          "operands": [
            "mailto:",
            "=join([$Atendees.email], ';')",
            "?Bcc=",
            "[$BCC.email]",
            "&subject=Event name: ",
            "[$Title]",
            "&body=Dear XXX,",
            "\r\n \r\n",
            "As you probably know, we have created the GT-wide overview for the handling the relevant external events, conferences, and trade shows: https://xxx",
            "\r\n",
            "The target is to have the single tool for all relevant events for SE GT to reach transparency, coordinate performance, use the synergies, and evaluate the efforts for the future.",
            "\r\n",
            "\r\n",
            "Furthermore, we want to learn from events where we have participated to evaluate our performance, and to learn for the participation in further events. For this purpose we have created the event feedback sheet: https://xxx, which you also can find in the above tool bar as per screenshot below.",
            "\r\n",
            "I kindly ask you to take approx. 9 Min. time and fill in this event to support us. As per our notes, you’ve participated in: ",
            "\r\n",
            "Furthermore, we store all conference proceedings (papers, publications, presentations, etc.) in: https://xxx to allow access for all GT staff.",
            "\r\n",
            "In case you as participant have got access to these documentation, please provide it to me for the uploading.",
            "\r\n \r\n",
            "Appreciating your support with kind regards,",
            "\r\n \r\n"
          ]
        }
      },
      "children": [
        {
          "elmType": "span",
          "style": {
            "display": "inline-block",
            "padding": "0 4px"
          },
          "attributes": {
            "iconName": "Mail"
          }
        },
        {
          "elmType": "span",
          "txtContent": {
            "operator": "+",
            "operands": [
              "Send email to ",
              {
                "operator": "?",
                "operands": [
                  "=length([$Atendees]) == 1",
                  "[$Atendees.title]",
                  "='all ' + length([$Atendees]) + ' members'"
                ]
              }
            ]
          }
        }
      ]
    }
    

    In this code, I removed ******@XXXX.com and

    " | Event date: ",
            "[$Startdate]",
    

    Because of adding these, the code doesn't work properly. I don't know if your problem has anything to do with these. Here is the result, it works fine:

    User's image

    08111


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


4 additional answers

Sort by: Most helpful
  1. Yanli Jiang - MSFT 31,596 Reputation points Microsoft External Staff
    2023-08-10T07:43:34.1733333+00:00

    Hi @Martin, Heidi (SE GP T SP PS) ,

    Please try this:

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "a",
      "style": {
        "display": "=if(length([$Atendees]) > 0, 'flex', 'none')",
        "text-decoration": "none"
      },
      "attributes": {
        "href": {
          "operator": "+",
          "operands": [
            "mailto:",
            "=join([$Atendees.email], ';')",
            "?Bcc=",
            "[$BCC.email]",
            "&subject=Event name: ",
            "[$Title]",
            "&body=Dear XXX,",
            "\r\n \r\n"
          ]
        }
      },
      "children": [
        {
          "elmType": "span",
          "style": {
            "display": "inline-block",
            "padding": "0 4px"
          },
          "attributes": {
            "iconName": "Mail"
          }
        },
        {
          "elmType": "span",
          "txtContent": {
            "operator": "+",
            "operands": [
              "Send email to ",
              {
                "operator": "?",
                "operands": [
                  "=length([$Atendees]) == 1",
                  "[$Atendees.title]",
                  "='all ' + length([$Atendees]) + ' members'"
                ]
              }
            ]
          }
        }
      ]
    }
    
    
    

    User's image

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Martin, Heidi (SE GP T SP PS) 571 Reputation points
    2023-08-10T08:22:04.6533333+00:00

    Hello @Yanli Jiang - MSFT,

    the code works, but unfortunately it no longer works with 12 recipients. Why is that? Can this still be adjusted?
    Here is the complete code:

    {
      "$schema": https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json,
      "elmType": "a",
      "style": {
        "display": "=if(length([$Attendees]) > 0, 'flex', 'none')",
        "text-decoration": "none"
      },
      "attributes": {
        "href": {
          "operator": "+",
          "operands": [
            mailto:,
            "=join([$Attendees.email], ';')",
            ?Bcc=xxx,
            "[$BCC.email]",
            "&subject=Event name: ",
            "[$Title]",
            " | Event date: ",
            "[$Startdate]",
            "&body=",
            "Dear XXX,",
            "\r\n \r\n",
            "As you probably know, we have created the GT-wide overview for the handling the relevant external events, conferences, and trade shows: https://xxx",
            "\r\n",
            "The target is to have the single tool for all relevant events for SE GT to reach transparency, coordinate performance, use the synergies, and evaluate the efforts for the future.",
            "\r\n",
            "\r\n",
            "Furthermore, we want to learn from events where we have participated to evaluate our performance, and to learn for the participation in further events. For this purpose we have created the event feedback sheet: https://xxx, which you also can find in the above tool bar as per screenshot below.",
            "\r\n",
            "I kindly ask you to take approx. 9 Min. time and fill in this event to support us. As per our notes, you’ve participated in: ",
            "\r\n",
            "Furthermore, we store all conference proceedings (papers, publications, presentations, etc.) in: https://xxx to allow access for all GT staff.",
            "\r\n",
            "In case you as participant have got access to these documentation, please provide it to me for the uploading.",
            "\r\n \r\n",
            "Appreciating your support with kind regards,",
            "\r\n \r\n"
          ]
        }
      },
      "children": [
        {
          "elmType": "span",
          "style": {
            "display": "inline-block",
            "padding": "0 4px"
          },
          "attributes": {
            "iconName": "Mail"
          }
        },
        {
          "elmType": "span",
          "txtContent": {
            "operator": "+",
            "operands": [
              "Send email to ",
              {
                "operator": "?",
                "operands": [
                  "=length([$Attendees]) == 1",
                  "[$Attendees.title]",
                  "='all ' + length([$Attendees]) + ' members'"
                ]
              }
            ]
          }
        }
      ]
    }
    
    
    0 comments No comments

  3. Yanli Jiang - MSFT 31,596 Reputation points Microsoft External Staff
    2023-08-15T03:17:14.0133333+00:00

    Hi @Martin, Heidi (SE GP T SP PS) ,

    The reason why it does not work may be that the link contains special characters, which will affect the Code. This can be avoided by placing the link alone.

    Please try this:

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "a",
      "style": {
        "display": "=if(length([$Atendees]) > 0, 'flex', 'none')",
        "text-decoration": "none"
      },
      "attributes": {
        "href": {
          "operator": "+",
          "operands": [
            "mailto:",
            "=join([$Atendees.email], ';')",
            "?Bcc=",
            "[$BCC.email]",
            "&subject=Event name: ",
            "[$Title]",
            "&body=Dear XXX,",
            "\r\n \r\n",
            "As you probably know, we have created the GT-wide overview for the handling the relevant external events, conferences, and trade shows:",
            "https://www.baidu.com",
            "\r\n",
            "The target is to have the single tool for all relevant events for SE GT to reach transparency, coordinate performance, use the synergies, and evaluate the efforts for the future.",
            "\r\n",
            "\r\n",
            "Furthermore, we want to learn from events where we have participated to evaluate our performance, and to learn for the participation in further events. For this purpose we have created the event feedback sheet: ",
            "https://www.baidu.com",
            ", which you also can find in the above tool bar as per screenshot below.",
            "\r\n",
            "I kindly ask you to take approx. 9 Min. time and fill in this event to support us. As per our notes, you’ve participated in: ",
            "\r\n",
            "Furthermore, we store all conference proceedings (papers, publications, presentations, etc.) in: ",
            "https://www.baidu.com",
            " to allow access for all GT staff.",
            "\r\n",
            "In case you as participant have got access to these documentation, please provide it to me for the uploading.",
            "\r\n \r\n",
            "Appreciating your support with kind regards,",
            "\r\n \r\n"
          ]
        }
      },
      "children": [
        {
          "elmType": "span",
          "style": {
            "display": "inline-block",
            "padding": "0 4px"
          },
          "attributes": {
            "iconName": "Mail"
          }
        },
        {
          "elmType": "span",
          "txtContent": {
            "operator": "+",
            "operands": [
              "Send email to ",
              {
                "operator": "?",
                "operands": [
                  "=length([$Atendees]) == 1",
                  "[$Atendees.title]",
                  "='all ' + length([$Atendees]) + ' members'"
                ]
              }
            ]
          }
        }
      ]
    }
    

    08151


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  4. Martin, Heidi (SE GP T SP PS) 571 Reputation points
    2023-09-13T09:30:39.3133333+00:00

    Hello @Yanli Jiang - MSFT,

    Is it possible to insert the link to the event element in the above code?

    At the moment only the event name appears here. But it would be great if you could put the link to this event element here.

    Thank you so much!

    User's image

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.