Skip to main content
16-Pearl
February 3, 2020
Solved

Html content( data getting from Infotable) using TWX email

  • February 3, 2020
  • 1 reply
  • 1769 views

Hi ,

 

I am trying displaying infotable field values in html table as email content or body.but it not taking as variable? can anyone help me for this query? below is code for displaying html content. its printing rowValue1 , rowValue2 as it is. I want their actual values .

 

var result = me.getDataForWeek(); //infotable result
var tableLength = result.rows.length;
logger.warn(tableLength);
for (var x=0; x < tableLength; x++) {
var row = result.rows[x];
logger.warn(row.M_Key);
var rowvalue1= row.M_Key;
var rowvalue2 =row.PowerFactor;
var emailContent = "<html><body>\
<table>\
<tr><td>M_Key</td><td>Powerfactor</td></tr>\
<tr><td>rowvalue1</td><td>rowvalue2</td></tr>\
</table></body></html>"
}

 

Thank you

Best answer by rosharma

// i haven't tested it at my end

but couple of things you can try at your end

 

1. try using + operator between the variable value like 

<tr><td>+rowvalue1+</td><td>+rowvalue2+</td></tr>\

2. try assigning Ids to your cells like

    <td id="rowvalue1">rowvalue1</td>

    <td id="rowvalue2">rowvalue2</td>

and then set their values in javascript like

document.getElementById("rowvalue1").innerHTML = rowvalue1;
document.getElementById("rowvalue2").innerHTML = rowvalue2;

 

1 reply

17-Peridot
February 3, 2020

Hi,

 

You are overwriting emailContent and the result is a html for the last object in the infotable.

Can you share what result you are getting?

 

Thanks,

Raluca Edu

16-Pearl
February 3, 2020
Hi,

What i have put in td tag same i am getting in result, but i want variable values.
When i take variable into logger.warn its printing correct values, but when i put those variables in html table tags its printing variable names instead their values.

Thank you
rosharma16-PearlAnswer
16-Pearl
February 3, 2020

// i haven't tested it at my end

but couple of things you can try at your end

 

1. try using + operator between the variable value like 

<tr><td>+rowvalue1+</td><td>+rowvalue2+</td></tr>\

2. try assigning Ids to your cells like

    <td id="rowvalue1">rowvalue1</td>

    <td id="rowvalue2">rowvalue2</td>

and then set their values in javascript like

document.getElementById("rowvalue1").innerHTML = rowvalue1;
document.getElementById("rowvalue2").innerHTML = rowvalue2;