Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Jacco_De_Zwart
Creator
Creator

RunIf does not seem to work

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

Labels (3)
1 Solution

Accepted Solutions
Jacco_De_Zwart
Creator
Creator
Author

GOT IT !!!!

 

After your hints, it kept me thinking. And after a few more experiments here's the result and it works !!!

 

0695b00000ofG91AAE.png

  • The tDBInput GetSourceTables qeuries the tables that need to be processed.
  • In the InterateTheTables I go over each of the records from the result set.
  • In WhichTableToProcess I set a global variable with the name of the table in the variable TableToProcess
  • In the Run-If trigger I check for the name of the table in the global variable with statement like :

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 :

0695b00000ofGBqAAM.pngSo thanks Sabrina and Fabio for you hints an keeping my train-of-thought going !!!

 

Jacco

View solution in original post

9 Replies
Anonymous
Not applicable

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

 

 

Jacco_De_Zwart
Creator
Creator
Author

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):

0695b00000ofFCEAA2.jpg 

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 ??

Anonymous
Not applicable

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

 

 

Jacco_De_Zwart
Creator
Creator
Author

. . . 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 ?

 

Fabio_Caimi
Contributor II
Contributor II

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.

 

Jacco_De_Zwart
Creator
Creator
Author

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 :

0695b00000ofFdjAAE.png 

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 :

0695b00000ofFdUAAU.png 

 

Jacco_De_Zwart
Creator
Creator
Author

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 ? ??

 

 

Jacco_De_Zwart
Creator
Creator
Author

GOT IT !!!!

 

After your hints, it kept me thinking. And after a few more experiments here's the result and it works !!!

 

0695b00000ofG91AAE.png

  • The tDBInput GetSourceTables qeuries the tables that need to be processed.
  • In the InterateTheTables I go over each of the records from the result set.
  • In WhichTableToProcess I set a global variable with the name of the table in the variable TableToProcess
  • In the Run-If trigger I check for the name of the table in the global variable with statement like :

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 :

0695b00000ofGBqAAM.pngSo thanks Sabrina and Fabio for you hints an keeping my train-of-thought going !!!

 

Jacco

Anonymous
Not applicable

Hello,

Great it works and feel free to let us know if there is any further help we can give.

Best regards

Sabrina