Seven Stars

Run IF Condition

Hi! Guys, what I wanna do Is sending a file with ftp only if one row from a table is less than 0.
I have the ftp connection with the connectpor "FTPPU" but I don't know how to do the condition. I mean, I have to start this ftput when the value from one row is "the condition". I tried to use the "run if" but when I put the condition "nameoftherow > 0" says that "nameoftherow" is not a variable.
I don't know If I have explained my problem very well, I hope you guys can help me because using "tmap" I know how to make condition, but I don't know how to make it using "run if" using row from my DB.
13 REPLIES
Seven Stars

Re: Run IF Condition

This is what I want to do.
Seven Stars

Re: Run IF Condition

Hi,
You need to get the data from the input component into a variable first and then check for the variable's value in the If condition.
Something like what I have done below
Get the value of the field/database column you want to check in a global variable in a tJavaRow component linked to your DB Input component. And then create a Run If link from the tJavaRow to the tFTPPut component to upload the file.
Hope this is helpful for you and suits your requirement.
Seven Stars

Re: Run IF Condition

 I tried to do this but I am having problems with the declaration of this global variable. I am really newbie at this u.u.
I will be watching how to do this, thank you for answering, it's really useful.
Seven Stars

Re: Run IF Condition

This is how you add a global variable:
globalMap.put("variable_name", variable_value);

This is how you retrieve the value of a global variable:
globalMap.get("variable_name");

One thing you must note is that you should know what is the type of value you are storing in this variable. As when you do a .get() you have to typecast the value to the appropriate Object type. This is because .get() generally returns an Object type and then comparing or processing on Object type is not possible unless you typecast it. 
For example, if I am storing an integer value in a global variable then when you do a .get() typecast the returned value with (Integer) to get the value in correct format to check or process.
Seven Stars

Re: Run IF Condition

On my database I have the row "number", which is an Integer. To get this variable I should do this?:
Int test= (Integer)globalMap.get("number");
or I have to define this row as a global variable first?
in this case what should I put there? globalMap.put("variable_name", variable_value);
Thanks.
Seven Stars

Re: Run IF Condition

So in this case, in the tJavaRow component you write the following
globalMap.put("rowNbr", row1.rownumber);

where row1 is the name of the Main link between the DB input and tJavaRow components.
And in the Run If trigger link between the tJavaRow and tFTPPut components the condition will be written as
((Integer)globalMap.get("rowNbr")) > 0
Seven Stars

Re: Run IF Condition

Thank you, it's really working. I am having a problem with my string now, I have a row with the value "1998" but I am getting false at run if. I am sure I have "1998" because at tjava row I am doing System.out.println(row1.id_maquina). The row type is VARCHAR.

Re: Run IF Condition

Hi dferre,
Use equals() method instead of "==". 
It will work fine.
Best Regards,
Amol Smiley Happy
Seven Stars

Re: Run IF Condition

Still not working, at "tjavarow" this works, I can make conditions with "if" and print the result but the "run if" doesn't work, I don't know what is happening. If tjavarow can detect my row, the "run if" condition should do too.

Re: Run IF Condition

Hi,
Can you please share screenshot of if condition..??
So I can find problem.
In if condition, write following statement to compare string
((String)globalMap.get("maqiuna")).equals("1998")
Best Regards,
Amol Smiley Happy
Seventeen Stars

Re: Run IF Condition

The if condition is pretty much the same as the trigger OnComponentOK but combined with a condition.
I guess the if condition is supposed to work per record. I suggest a different design:
tDBInput --row1--> tFilterRow ----> tFlowToIterate --Iterate--> tFTPPut
I guess the tJavaRow was simply a kind of anchor? If there was some logic, add it before the filter in the flow.
Seven Stars

Re: Run IF Condition

Hi,
Can you please share screenshot of if condition..??
So I can find problem.
In if condition, write following statement to compare string
((String)globalMap.get("maqiuna")).equals("1998")
Best Regards,
Amol Smiley Happy

Just like this.
Seven Stars

Re: Run IF Condition

The if condition is pretty much the same as the trigger OnComponentOK but combined with a condition.
I guess the if condition is supposed to work per record. I suggest a different design:
tDBInput --row1--> tFilterRow ----> tFlowToIterate --Iterate--> tFTPPut
I guess the tJavaRow was simply a kind of anchor? If there was some logic, add it before the filter in the flow.

This worked! Thank you : )