Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

HTML not rendering in HTML Content visual

I'm using HTML Content visual.

I created a measure which embeded my HTML code:

``

HTML = "
<!DOCTYPE html>
<html lang=""en"">
<head>
  <meta charset=""UTF-8"">
  <meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
  <title>Document</title>
  <style>
    .container{
      display: flex;
      justify-content: center;
    }
    .opp-name{
      color:#d70927;
      font-family: Arial, Helvetica, sans-serif;
    }
  </style>
</head>
<body>
  <div class=""container"">
    <p class=""opp-name"">"&SELECTEDVALUE('Opportunité'[Name])&"</p>
    " & SELECTEDVALUE('Opportunity Feed'[Body]) & "
  </div>
</body>
</html>
"

``

'Opportunité'[Name] renders properly, 'Opportunity Feed'[Body] is not rendering.

In 'Opportunity Feed'[Body], it contains HTML tags and content. For example: <p>Email relance sent à Ingrid &gt;&gt; Reponse</p><p>Je reviens vers vous</p>

If I just drop 'Opportunity Feed'[Body] alone in HTML Content visual, it renders properly.

  • Have you checked the granuality? Maybe there are duplicates? 

    If you change the SELECTEDVALUE of 'Opportunity Feed'[Body] to MAX of 'Opportunity Feed'[Body] --- you should see it return text?

  • It's possible you could use CONCATENATEX in your DAX

6 Replies

  • KerKol's avatar
    KerKol
    Power Participant

    Have you checked the granuality? Maybe there are duplicates? 

    If you change the SELECTEDVALUE of 'Opportunity Feed'[Body] to MAX of 'Opportunity Feed'[Body] --- you should see it return text?

    • Anonymous's avatar
      Anonymous
      Not applicable

      You are right. There are duplicate values that I didnt notice: 

      In this case, I would like to display both values like this:

      30/10/2024 11:15:54

      <p> AS Lorea Belette....</p>

      17/10/2024 13:34:30

      <p> Email relance colle....</p>

       

      I'm thinking that I could use JavaScript to make an array and then use HTML to display this in the iframe.

      Does this visual also render JS?

      • KerKol's avatar
        KerKol
        Power Participant

        No it doesn't. Could you create an index field? it's hard to advise without seeing what you are trying to build...

         

  • Most likely it contains too many tags ( like <body>  etc).  See if you can clean that up, or if you can isolate it in its own iframe.

    • Anonymous's avatar
      Anonymous
      Not applicable

      You mean in my 'Opportunity Feed'[Body] column there might be <body> tag?

      There isn't any <body> tag, but in some records there are a lot of <p> tag.

      To test your solution, I created a new column 'Opportunity Feed'[Test]. In this column, all the records are "<p>Test</p>". 

      When I changed my measure from  SELECTEDVALUE('Opportunity Feed'[Body]) to SELECTEDVALUE('Opportunity Feed'[Test]), "Test" is rendered in the iframe, but opportunity name is not rendering any more.

      This is really odd.