Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi there,
I have the following situation :
tDBinput --> tJavaRow --> RunIf-trigger --> SubJob To be executed when RunIf condition is true
RunIf-trigger
--> SubJob To be executed when RunIf condition is true
In the tJavaRow component I have to following code to set a context variable which I want to use in the run-if trigger:
context.setProperty("TableToProcess", row1.source_table)
in the RunIf-trigger I use :
context.getProperty("TableToProcess").equals("
AKTKONPF
")to trigger the sub-job when the value of the context variable is "AKTKONPF"
The line
context.getProperty("TableToProcess").equals("AKTKONPF") results in true or false, but when places in the RunIf-trigger, it is allways false.
What am I doing wrong ??
Thanks in advance.
Jacco
GOT IT !!!!
After your hints, it kept me thinking. And after a few more experiments here's the result and it works !!!
globalMap.get("TableToProcess").equals("AKTKONPF")
So even if the query returns 5 tables that need to be processed, and only 3 are matched in the Run-If trigger, only those tables are actually processed. And if there is a Run-If trigger configured for a table that is not in the resultset of tDBInput GetSourceTables, that Run-If trigger results in False and will not be executed.
In my experiment the result is a count of the records in the tables that needed processing :
So thanks Sabrina and Fabio for you hints an keeping my train-of-thought going !!!
Jacco
Hello,
If you are creating some variables in tJavaRow, then you can assign them to globalMap varibles like
'globalMap.put("myVar","myVarValue")' in tJavaRow.
For example
on tJavaRow:
if(row1.source_table.equals("AKTKONPF")){
globalMap.put("TableToProcess", true);
}else{
globalMap.put("TableToProcess", false);
}
set the condition of runIf trigger:
(Boolean)globalMap.get("TableToProcess") or !(Boolean)globalMap.get("TableToProcess") which is depended on your needs.
Hope it helps for you.
Best regards
Sabrina
Hi Sabrina,
Thanks for your response !
What I actually want to do is this :
I first get al list of all the tables I want to process. Based on the name of the table I have to do something different with the data from that table.
So based on the query results I check which part of the flow I need to take with tJavaRow :
globalMap.put("TableToProcess", row1.source_table):
Then with the Run-If trigger check which part of the flow I need to take. For instance, with two tablenames AKTKONPF and DOSADFPF I have one Run-If
(Boolean)globalMap.get("TableToProcess").equals("AKTKONPF")
and an other one
(Boolean)globalMap.get("TableToProcess").equals("DOSADFPF")
The problem is, is that the checks in the Run-If doesn't seem to work.
What am I doing wrong ??
Hello,
With your use case, you need to use "if...else" method in tjavarow and
the data Type "boolean" will return to true or false.
Best regards
Sabrina
. . . so for each table I want to process, I need a boolean type global variable ?
so in tJavaRow would look like :
if(row1.source_table.equals("AKTKONPF")){
globalMap.put("TableToProcessAKTKONPF", true);
}else{
if(row1.source_table.equals("DOSADFPF"))
{
globalMap.put("TableToProcessDOSADFPF", true);
}
}
and in each Run-If trigger :
(Boolean)globalMap.get("TableToProcessAKTKONPF") in order to process the AKTKONPF table
and in the other Run-If trigger :
(Boolean)globalMap.get("TableToProcessDOSADFPF") in order to process the DOSADFPF table
Is that what you mean ?
Hi Mr. Black,
Are you printing something in tLogRow_1 and tLogRow_2?
I suggest you to rely on the tLogRow output rather than the designer preview.
Because in your row1 I see 5 rows, but the "false" state you read in the 2 IFs of the preview refers only to the last and 5th row.
Fabio,
The tLogRow's are just for testing purposes only.
The query result in tDBInput results in a list of table names. Two of them are AKTKONPF and DOSADFPF, which in my idea would fire the Run-If triggers because of the condition like (Boolean)globalMap.get("TableToProcess").equals("AKTKONPF") in the first and (Boolean)globalMap.get("TableToProcess").equals("DOSADFPF") in the second.
The result of the tDBInput GetSOurceTables is a simple list :
So, both of the Run-If trigger should fire because the value of TableToProcess is set with the right values. And therefor, both the tLogRow's should show some result as a matter of test. The tLogRows should show the row count of both tables, the query in tDBInput is a simple select count() from AKTKONPF and select count() from DOSADFPF. Just to see is something is executed.
Based on the designer screen, it doesn't seem to work, but all so there is no result at run-time :
small addition. ....
it works for just one (1) table.
If I limit the query of GetSourceTables to 1 row, it works. The table AKTKONPF is the first in the query result.
If I limit the query to 3, then DOSADFPF is the 3th record, it only works for DOSADFPF table. Not for AKTKONPF table, which came first.
Do I need an iterate or something ? ??
GOT IT !!!!
After your hints, it kept me thinking. And after a few more experiments here's the result and it works !!!
globalMap.get("TableToProcess").equals("AKTKONPF")
So even if the query returns 5 tables that need to be processed, and only 3 are matched in the Run-If trigger, only those tables are actually processed. And if there is a Run-If trigger configured for a table that is not in the resultset of tDBInput GetSourceTables, that Run-If trigger results in False and will not be executed.
In my experiment the result is a count of the records in the tables that needed processing :
So thanks Sabrina and Fabio for you hints an keeping my train-of-thought going !!!
Jacco
Hello,
Great it works and feel free to let us know if there is any further help we can give.
Best regards
Sabrina