Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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.
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.
@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
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 ?
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.
@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
Anyway, Thanks for your tips @Shicong Hong 🙂
Do you have any idea about this false ? I do not understand why is it not working... I have 2 rows in my file csv
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?