Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Roman01
Contributor II
Contributor II

No data in file CSV in mail

Hello Community,

I develop a job talend for the invoices. I have an issue about to send a mail to inform the team that there are no invoice in the tMap with an inner join reject.

When I use the component TSendMail after a tfileOutPutDelimited, there are no data in my CSV file in the mail. ( pictures 01 and 02)

However, when I use a tFileInputDelimited and the tSendMail in an another job to test the csv file data in mail, I get the data in my CSV file in the mail... Do you know where is the problem ?

Also, when I use the second job to only send mail, I received twice... (picture 05) Are there an option to send only one mail ?

Thanks a lot,

Romain.

Labels (5)
11 Replies
Anonymous
Not applicable

Hello,

 

The reason for this behavior is because your CSV data isn't flushed to the disk when the e-mail is sent.

Are you trying to send 1 e-mail at the end of the workflow? Try to use OnComponentOK from the CSV output. Or even better use OnSubjobOK from the wf_FactureEnvoye input.

 

When you received 2 e-mails I think that is because you had 2 lines in your data flow.

 

A third behavior could be achieved by enabling "Output in row mode" under the Advanced settings of CSV. I think this will give you N e-mails, and the attachments would have 0,1,2...N records.

Roman01
Contributor II
Contributor II
Author

Hello Bgunics,

 

 

It works fine with the trigger 'OnComponentOk'. So what is the best practice in Talend so what is the difference between Main and the trigger ?

 

However the job send mail the mail even I have 0 row in file error.

Do you know how to not send mail if no data in the tFileOutPutDelimited with the trigger 'IF'?

 

Thanks in advance.

Anonymous
Not applicable

@Romain ADICEOM​ , there is a global variable that counts the total number processed rows,

((Integer)globalMap.get("tFileOutputDelimited_1_NB_LINE"))

You can use this variable to determine if sending the email or not.

....tFileOutputDelimited---runIf--tSendmail

 

set the condition of runIf as:

((Integer)globalMap.get("tFileOutputDelimited_1_NB_LINE"))>0

 

Hope it helps!

 

Regards

Shong

 

Roman01
Contributor II
Contributor II
Author

Thanks a lot @Shicong Hong​ !

 

It works fine. However, to understand this condition, is it include header count in global variable ?

 

Because I use also this another method to not send mail with a tFileRowCount and tJava :

Here, I have one row and when I do :

 ((Integer)globalMap.get("tFileRowCount_1_COUNT"))==1 , it's written False and when I do this :

 ((Integer)globalMap.get("tFileRowCount_1_COUNT"))==2, it works fine, so I deduce this way include the header

 

Am I right ?

 

0695b00000JM4CQAA1.jpg

Anonymous
Not applicable

yes, you can also use tFileRowCount to populate the number of lines after generating the output file, the global variable ((Integer)globalMap.get("tFileOutputDelimited_1_NB_LINE")) counts the number of processed rows (not includes header rows) are written into output file, I would like to use the global variable, as it is more convenient and understandable.

 

Roman01
Contributor II
Contributor II
Author

@Shicong Hong​ 

I think this way works when the file is already written and use a tFileInputDelimited but in my job the flush is not finished. So I have still a false, I will try with a tJava and tFilterRowCount

 

0695b00000JM4JqAAL.jpg

Roman01
Contributor II
Contributor II
Author

Anyway, Thanks for your tips @Shicong Hong​  🙂

Roman01
Contributor II
Contributor II
Author

Do you have any idea about this false ? I do not understand why is it not working... I have 2 rows in my file csv0695b00000JM4TqAAL.jpg

Anonymous
Not applicable

For debugging, print the value of the global variable on tJava to see how many rows are processed?

It is a new file created or you append records to an existing file?