Dynamically add Multiple Rows in A HTML Template

Hi All,

 

I have a use case where I need to send a mail using html template. can anyone provide me the syntax to Dynamically add Multiple Rows in A HTML Template.

  Discussion posts and replies are publicly visible

  • Hi Sunnya,

    I haven't worked on this use case, but I can give some idea, Create a dynamic rule and call that rule in excel template.

    <html>
    <body style='font-family:calibri;'>
    <BR>
    <!--Email Header - Ends Here-->
    <!--Email Message Contents - Starts Here - CUSTOMIZE TO YOUR NEEDS-->
    Hello,
    <br/>
    ###table###
    </body>
    </html>


    While configuring the ###table### you can call that rule actually populates the dynamic Table.

  • in the place of ###table### you can pass the following code

    "<table border=1 style='font-family:Calibri;'>
    <tr>
    <th style='border: 1px solid black;'>Header 1</th>
    <th style='border: 1px solid black;'>Header 2</th> ......
    <th style='border: 1px solid black;'>Header n</th>
    </tr>"&apply(rule!TableRowsEmail(_),ri!yourCDT)&"</table>"

    in the rule rule!TableRowsEmail(_) have the following code

    "<tr><td style='border: 1px solid black;'>" & ri!yourCDT.field1 & "</td><td style='border: 1px solid black;'>" & ri!yourCDT.field2 & "</td><td style='border: 1px solid black;'>" & ri!yourCDT.field3 & "</td><td style='border: 1px solid black;'>" & ri!yourCDT.fieldn & "</td><td>" & "</td></tr>"
  • Hi Sunanya,

    You must have template as Chandu mentioned in the other post like below. This is just a sample

    <style type="text/css">
    .tg {border-collapse:collapse;border-spacing:0;}
    .tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 10px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
    .tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 10px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
    .tg .tg-baqh{text-align:left;vertical-align:top}
    .tg .tg-hgcj{font-weight:bold;text-align:left}
    .tg .tg-amwm{font-weight:bold;text-align:left;vertical-align:top}
    </style>
    <p>Hello Team,</p>
    <p>Below are the details of the tasks </p>
    <table class="tg">
    <tr>
    <th class="tg-hgcj">Task</th>
    <th class="tg-amwm">Owner</th>
    <th class="tg-amwm">EOD</th>
    <th class="tg-amwm">Due Date</th>
    <th class="tg-amwm">Dependency</th>
    </tr>
    ###emailHTMLTableBody###
    </table>

    <p>Thanks & Regards,</br>
    Test Admin</p>

    Next step you have to configure something like below in the email template configuration.
    emailHTMLTableBody=pv!emailHTMLTableBody

    then you can construct your own content in html format in pv!emailHTMLTableBody like below

    "<tr>"&
    "<td class="&"tg-baqh"&">" & "Task Name" &"</td>"&
    "<td class="&"tg-baqh"&">" & "Test Owner" &"</td>"&
    "<td class="&"tg-baqh"&">" & "Test Date" &"</td>"&
    "<td class="&"tg-baqh"&">" & "Test EOD" &"</td>"&
    "<td class="&"tg-baqh"&">" & "Test Sent" &"</td>"&
    "<td class="&"tg-amwn"&">"&"<font color="&"red"&">"&"<col width="&"""150"""&">"&"Test Dependency" &"</font>"&"</td>"&
    "</tr>"

    You can do it in this way. You can either create tables or anything which is supported by html.

    If you have huge data then you use json then you have to write down code in the script and pass the actual json to that html and then you can create table using java script as well in direct html page using some manual coding. it is intern tricky. For simple thing you can follow above procedure.