Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Dears,
I am trying to get data from MySQL and eventually send it as html email messsage.
I read many articles here but dont understand issue with my flow.
I am getting results, but email content dont show "FirstName" while email sending is fine.
In context option i added one string as "Fname" and in my table i have one "FirstName" column.
in tJavaRow components i added this code :
context.FName= input_row.FirstName;
And then in tSendMail message added :
context.FName
Please advise what i am doing wrong. Thanks
Here is my tJavaRow (with correction on html syntax):
String msg = ((String)globalMap.getOrDefault("mailMsg", "<table><tr><th>ID</th><th>FirstName</th><th>LastName</th></tr>"));
msg = msg +
"<tr>" +
"<td>" + input_row.Id + "</td>" +
"<td>" + input_row.FirstName + "</td>" +
"<td>" + input_row.LastName + "</td>" +
"</tr>";
globalMap.put("mailMsg", msg);and here is what tJava print on the console:
[statistics] connecting to socket on port 3767
[statistics] connected
.--+---------+--------.
| tLogRow_40 |
|=-+---------+-------=|
|Id|FirstName|LastName|
|=-+---------+-------=|
|1 |AAA |BBB |
|2 |ABC |DEF |
|3 |DEF |GHI |
'--+---------+--------'
<table><tr><th>ID</th><th>FirstName</th><th>LastName</th></tr><tr><td>1</td><td>AAA</td><td>BBB</td></tr><tr><td>2</td><td>ABC</td><td>DEF</td></tr><tr><td>3</td><td>DEF</td><td>GHI</td></tr>
[statistics] disconnected
Do you have synchrnized your tJavaRow schema?
If not, do it and retry.
If you want to send 1 email per record, you need to add a tFlowToIterate after the tJavaRow component then connect it to tSendMail and use the global variables created by tFlowToIterate.
Dear TRF,
I want to send multiple records in one email. my template will contain several records.
The problem i am facing is with assigning data.
What should i add in tJavaRow components: context.FirstName = ??
My table results are like below.
In Email Message:
"Hello, The input message is " + context.FirstName
Context.FirstName dont have any value. Please advise. Thanks
You need to do "context.Firstname = input_row.FirstName" but, because of the job design, you'll get only the last value.
Give an example of the input data and the expected email you want to build.
Dear TRF,
I am using "context.FirstName= input_row.FirstName" but even dont get last row value.
My Input data is from mySQL Table, it contain following data which is in tLogRow.
I will print simple html table like below in email. My Job Design is in above post, please advise. Thanks
ID FirstName LastName
| 1 | AAA | BBB |
| 2 | ABC | DEF |
| 3 | DEF | GHI |
Update:
Now i added 3 variables in context as ID(int),FirstName(string),LastName(string).
In tJavaRow component added:
context.ID= input_row.ID; context.FirstName = input_row.FirstName; context.LastName = input_row.LastName;
and in tSendMail Message added:
context.ID +" "+ context.FirstName + " " + context.LastName
And now in email i am getting null as result.
You want to build a html table to be included into the email message, right?
So, what you're doning is not enough.
Based on your job design, you need to construct the html table row by row into your tJavaRow, like this:
String msg = ((String)globalMap.getOrDefault("mailMsg", "<table><tr><th>Id</th><th>Firstname</th><th>Lastname</th>"));
msg = msg +
"<tr><td>" + input_row.ID + "</td>" +
"<tr><td>" + input_row.FirstName + "</td>" +
"<tr><td>" + input_row.LastName + "</td>";
globalMap.put("mailMsg", msg);Then, in tSendMail, use the global variable to complete the message field and close the html table:
((String)globalMap.get("mailMsg")) +
"</table>"
Dear TRF,
This is strange that in email i am still getting "null ". While in tLogRow i am getting proper results.
Mapping from tLogRow and tJavaRow is also correct , as below. What possible can be wrong with this.
Looks OK but as it doesn't make the expected job (building a html table), I suggest you to use the code from my previous answer.
Dear TRF,
Now i changed the code like below, but still getting null. I think this tJavaRow is not suitable for this , but alot of people on this forum are using it. I tried many ways still getting null in email output.
context.ID= input_row.ID;
context.FirstName = input_row.FirstName;
context.LastName = input_row.LastName;
String msg = ((String)globalMap.getOrDefault("mailMsg", "<table><tr><th>ID</th><th>FirstName</th><th>LastName</th>"));
msg = msg +
"<tr><td>" + context.ID + "</td>" +
"<tr><td>" + context.FirstName + "</td>" +
"<tr><td>" + context.LastName + "</td>";
globalMap.put("mailMsg", msg);
Correct code in tJavaRow should look like this (sorry):
String msg = ((String)globalMap.getOrDefault("mailMsg", "<table><tr><th>ID</th><th>FirstName</th><th>LastName</th>"));
msg = msg +
"<tr><td>" + context.ID + "</td></tr>" +
"<tr><td>" + context.FirstName + "</td></tr>" +
"<tr><td>" + context.LastName + "</td></tr>";
globalMap.put("mailMsg", msg);However, this not the reason why you get null in email (and for information, I use a tJavaRow to construct this kind of message in many jobs).
Can you share the tSendMail settings?
Can you also explain why you want to use context variables and what you expect from them?