Skip to main content
Feb 3, 2020 12:42 PM UTC
Solved

Html content( data getting from Infotable) using TWX email

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

rosharmaAnswer
Feb 3, 2020 6:31 PM UTC

// 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;

 

5 replies

Feb 3, 2020 1:36 PM UTC

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

Feb 3, 2020 5:20 PM UTC
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
rosharmaAnswer
Feb 3, 2020 6:31 PM UTC

// 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;