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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
gadje1
Creator
Creator

How output values from tJava 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 :

 

0683p000009M5re.jpg

 

Labels (2)
1 Solution

Accepted Solutions
nfz11
Creator III
Creator III

At the end of your tJava write:
globalMap.put("etat",etat);

And in your if connector write:
((Integer)globalMap.get("etat")) == 1

View solution in original post

4 Replies
nfz11
Creator III
Creator III

Try putting the etat variable into the globalMap and reading it in the 'if' connections from there.  It might not work as a row variable like you have it.

gadje1
Creator
Creator
Author

I tried to declare my variable "int output_row1;" in my tJava code.

And i did this "((Integer)globalMap.get("output_row1.etat")) == 1" in my Run if connector.
But it's not better.
i have this error message : "he left-hand side of an assignment must be a variable"
nfz11
Creator III
Creator III

At the end of your tJava write:
globalMap.put("etat",etat);

And in your if connector write:
((Integer)globalMap.get("etat")) == 1

gadje1
Creator
Creator
Author

Thanks a lot for your respons. Everything works now with your solution.