Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
talendstar
Creator
Creator

Send query result by mail

Using what is described in following link:

https://community.talend.com/t5/Design-and-Development/resolved-Sending-query-result-by-mail/m-p/100...

 

I am able to send the query results by email but the email is print results column after column and not in row.

By that I mean if my table looks like this:

 

Name   Date

John     05-08-2019

Nas      05-07-2019

 

The email that I get is this:

Name:

John

Nas

Date:

05-08-2019

05-07-2019

 

This is what I have in tjavarow:

context.StepName = context.Name+"\n"+input_row.Name;
context.Timestamp = context.Timestamp+"\n"+input_row.Timestamp;

 

And this is how the email message in tsendMail is composed:

"Name: "+context.StepName+ " Date:" + context.Timestamp+"."

 

What I would like to see in the result is each row with column header:

 

Name   Date

John     05-08-2019

Nas      05-07-2019

 

How can I accomplish this?

0683p000009M4QS.png

Thanks

Labels (1)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi,

 

    Your email component is called after tjavarow data processing using on SubJob Ok.

 

So the context.StepName is havig data as below

 

Name:
John
Nas

   since you have given the code as shown below. It means, the data of name will get continously accumulated to the StepName column one after another.

   context.StepName = context.Name+"\n"+input_row.Name;

 

   Instead of this, you can do a simple trick.

 

Assign the initial value of context.Step as shown below.

 

context.Step="Name"+"\t"+"Date";

Inside tjavarow, add as below.

 

context.Step= context.Step+"\n"+input_row.Name+"\t"+input_row.Timestamp;

Then, use the context.Step inside your existing tSendmail (which is connected using OnSubJobOk). This should reslve your issue 🙂

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

 

 

 

 

    

View solution in original post

3 Replies
Anonymous
Not applicable

Hi,

 

    Your email component is called after tjavarow data processing using on SubJob Ok.

 

So the context.StepName is havig data as below

 

Name:
John
Nas

   since you have given the code as shown below. It means, the data of name will get continously accumulated to the StepName column one after another.

   context.StepName = context.Name+"\n"+input_row.Name;

 

   Instead of this, you can do a simple trick.

 

Assign the initial value of context.Step as shown below.

 

context.Step="Name"+"\t"+"Date";

Inside tjavarow, add as below.

 

context.Step= context.Step+"\n"+input_row.Name+"\t"+input_row.Timestamp;

Then, use the context.Step inside your existing tSendmail (which is connected using OnSubJobOk). This should reslve your issue 🙂

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

 

 

 

 

    

talendstar
Creator
Creator
Author

That worked.

 

Thanks for your help.

Anonymous
Not applicable

Hi nikhilthampi,

I followed your explanation for that post, but got slighlty differnt results than wanted.

instead of geting all query results in the mail i only get the last row.

I guess tjava overright the context var each time, but dont know how to fix that.

 

This is the Log before Javarow:

0683p000009M8mV.jpg

JavaRow:

context.header="player_id"+"\t"+"Alert"+"\t"+"timecreated";
context.output=context.header+"\n"+input_row.player_id+"\t"+input_row.Alert+"\t"+input_row.timecreated;

tSendMail:

context.output

and that is what i get in mail:

0683p000009M8vH.jpgonly 1 line

 

 

this is the full Job:

0683p000009M8sY.jpg