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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
gadje1
Creator
Creator

Output values from tJava and input it in trigger "Run if"

Hello,
I would like to execute one action or another depending on the result of a tJava component.
If the job runs before 15:00, the trigger (if_10_15) will be executed.
If the job is executed after 15:00, it will be the trigger (if_15_18) that will be executed.
I do not know how to do this. I put an exit in each of my conditions of my tJava (row1.etat) and connected it via a trigger "Run if" containing the conditions if (row1.etat == -1), if (row1.etat == 0) and if (row1.etat == 1).
But I have some errors.
If anyone could show me the right way, it would be nice.
Thank you in advance.


My tJava code :

SimpleDateFormat dateformat = new SimpleDateFormat("hh:mm"); 
Date hLim = dateformat.parse("15:00"); 
String pattern = "HH:mm"; 
Date hNow = new Date();
int etat = TalendDate.compareDate(hNow, hLim, pattern);

// Faire passer la valeur de etat en argument au "Trigger Run if" 
if (etat == -1){
	System.out.println(etat + " / " + hNow + " / " + " Tournée demain matin");
	row1.etat = etat;
} 
if (etat == 0){
	System.out.println(etat + " / " + hNow + " / " + " Tournée demain matin");
	row1.etat = etat;
} 
else if (etat == 1){
	System.out.println(etat + " / " + hNow + " / " + " Tournée demain après-midi");
	row1.etat = etat;
}

My job structure :

0683p000009M6Au.jpg

Labels (3)
2 Replies
Anonymous
Not applicable

Hello,

What's the error are you getting when you use tJava custom code in your job?

Here is a component tWaitForFile which iterates on a directory and triggers the next component when the defined condition is met.

https://help.talend.com/reader/HP30FGhc6Q9LiHefZVu4yw/xygPn~ESNbYiVEUQlhIr9A

Best regards

Sabrina

navds
Creator II
Creator II

Hi,
Variable defined in tJava has a scope in the Run-If connection.
I would do:
boolean runMorningTour = TalendDate.compareDate(hNow, hLim, pattern) <= 0;
Then if the runif, respectively, runMorningTour and !runMorningTour

Cheers,
Navds