How to convert Teams Conversations(HTML) to JSON in Sharepoint

404 views Asked by At

I am trying to publish a Teams Channel in Sharepoint. By using Power Automate i use the trigger "When new message is sent". But since the Lists in Sharepoint can't take HTML i have to convert the messages HTML into text. The problem is that if the message includes hyperlinks or pictures etc, it really looks aweful on Sharepoint.

Is there a way to get all relevant information from the messeage and display it correctly in the Formatt View in Sharepoint?

Another problem is that i seem not able to use $CreatedDate in the formatting view. It won't show up.

This is the JSON code I currently use for the formatting:

    {
  "schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "debugMode": false,
  "hideSelection": true,
  "hideColumnHeader": true,
  "rowFormatter": {
    "elmType": "div",
    "attributes": {
      "class": "ms-borderColor-neutralLight"
    },
    "style": {
      "flex-direction": "row",
      "align-items": "stretch",
      "box-sizing": "border-box",
      "border-width": "1px",
      "border-left-width": "4px",
      "border-style": "solid",
      "margin-bottom": "10px"
    },
    "children": [
      {
        "elmType": "div",
        "style": {
          "padding": "10px 10px"
        },
        "children": [
          {
            "elmType": "div",
            "style": {
              "margin-right": "10px"
            },
            "children": [
              {
                "elmType": "img",
                "attributes": {
                  "src": "= @currentWeb + '/_layouts/15/userphoto.aspx?size=L&accountname='+[$From.email]+'&UA=0&size=HR48x48'",
                  "title": "[$From.email]"
                },
                "style": {
                  "border": "1px solid #808080",
                  "border-radius": "50%",
                  "left": "50%",
                  "width": "48px",
                  "height": "48px",
                  "display": "flex"
                }
              }
            ]
          }
        ]
      },
      {
        "elmType": "div",
        "style": {
          "box-sizing": "border-box",
          "padding": "0 20px",
          "border-left": "3px solid black"
        },
        "children": [
          {
            "elmType": "div",
            "style": {
              "flex": " 1 0 300px"
            },
            "children": [
              {
                "elmType": "div",
                "style": {},
                "children": [
                  {
                    "elmType": "div",
                    "style": {
                      "display": "flex",
                      "flex-direction": "row"
                    },
                    "children": [
                      {
                        "elmType": "div",
                        "attributes": {
                          "class": "ms-font-m"
                        },
                        "style": {
                          "line-height": "1.5em",
                          "margin": "8px 0",
                          "font-weight": "bold"
                        },
                        "txtContent": "=[$From.title]+', '",
                        "children": []
                      },
                      {
                        "elmType": "div",
                        "attributes": {
                          "class": "ms-font-m"
                        },
                        "style": {
                          "line-height": "1.5em",
                          "margin": "8px 0",
                          "font-weight": "bold"
                        },
                        "txtContent": "=toLocaleString([$DateCreated])"
                      }
                    ]
                  },
                  {
                    "elmType": "div",
                    "attributes": {
                      "class": "ms-font-xxl"
                    },
                    "style": {
                      "line-height": "1.5em",
                      "color": "#0077FF",
                      "margin": "8px 0"
                    },
                    "txtContent": "[$Title]"
                  },
                  {
                    "elmType": "div",
                    "attributes": {
                      "class": "ms-font-m"
                    },
                    "style": {
                      "line-height": "1.5em",
                      "margin": "8px 0"
                    },
                    "children": [
                      {
                        "elmType": "div",
                        "style": {
                          "display": "inline-block"
                        },
                        "children": [
                          {
                            "elmType": "span",
                            "attributes": {
                              "class": "ms-fontWeight-semibold"
                            },
                            "style": {
                              "margin-right": "18px"
                            },
                            "txtContent": "[$Message]"
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "elmType": "a",
                    "iconName": "Mail",
                    "class": "sp-field-quickActions",
                    "href": "[$DeepLink] + [$ID]"
                  },
                  {
                    "elmType": "a",
                    "style": {
                      "display": "inline-block",
                      "padding": "0 74x"
                    },
                    "class": "sp-field-quickAction",
                    "attributes": {
                      "iconName": "Mail",
                      "target": "_blank",
                      "href": "[$DeepLink]"
                    }
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  }
}

This is the flow seutp I use for trigger and request: https://mattipaukkonen.com/2019/10/04/low-code-solution-for-publishing-teams-conversations-on-sharepoint/

0

There are 0 answers