One Star

How to use Trigger Run If

How can I use trigger Run If in my application.I am using tReplicate to replicate data into n nuber of branch. I want branches should be executed on certain condition.

  • Data Integration
18 REPLIES
One Star

Re: How to use Trigger Run If

Have a look at this post.
One Star

Re: How to use Trigger Run If

I am unable to understand that post. Please see image attached. after tReplicate job should be executed on certain condition.
One Star

Re: How to use Trigger Run If

Hi shaky,
Have you considered putting tFilterRow components after your tReplicate? Your branches could then be executed based on certain conditions on your data. It is not an all-or-nothing-run-if component, but a per-row-run-if component.
Daniel
One Star

Re: How to use Trigger Run If

How can I execute all or nothing condition...
One Star

Re: How to use Trigger Run If

You can't. As I suggested in the post I referred you to, the best you can do (other than filtering) is to use a tHashOutput or tFileDelimitedOutput instead of tReplicate and then have a series of RunIfs with your condition from that output component to a corresponding input component.
One Star

Re: How to use Trigger Run If

how to set if condition..in your image its If(order:1). how did you set that? order is field in schema?
One Star

Re: How to use Trigger Run If

Right click on a component and select Trigger > Run if. Then click on the If link and in the Component tab, type your boolean expression e.g. context.ExecutePath==1. Click on the link again to name it with something meaningful.
The displayed order of the If conditions is the order they are executed. That order defaults to the order you create them but you can right-click on any of them and "Modify If links order".
One Star

Re: How to use Trigger Run If

I want to read properties files along with my job running and frpm properties files i want value to check condition. how can I use contextload along with my job
One Star

Re: How to use Trigger Run If

Read the help on tContextLoad, which sets out an example of how to read properties from a file and apply them in a job. Then simply reference the context values in your RunIf expressions.
One Star

Re: How to use Trigger Run If

Does the Run If (that you explained) in the prior posts only work with Boolean expressions? Can we use it with an Integer (for example),
Run If (flag ==1), Run If (flag ==2) etc etc
One Star

Re: How to use Trigger Run If

The result of the expression must be true or false but you can use any data types or methods you want in determining the end result e.g.
context.FilePath.startsWith("C:\\") && context.TestDate.before(TalendDate.parseDate("yyyy-MM-dd","2009-06-30"))
|| context.RunNumber==1 && context.MaxValue.compareTo(BigDecimal.valueOf(100000.00))<0
One Star

Re: How to use Trigger Run If

Thanks for your response alevy!
Well, that is where I am confused. If you use a boolean expression for the Run_If branches, we can only have two branches right (true or false). What if we needed more than three "Run_if" branches from a tJavaRow or a tJava component? That led me to use a flag of type Integer (flag =1 or flag =2 or flag =3) but I am getting a tJavaRow error with a type mismatch.
One Star

Re: How to use Trigger Run If

The expressions in each of the RunIfs are independent and do not have to be complementary i.e. you can have none or more than one RunIf triggered if that's what you want e.g.
RunIf (order:1) - context.FilePath.startsWith("C:\\")
RunIf (order:2) - context.FilePath.equals("")
RunIf (order:3) - context.TestDate==null
RunIf (order:4) - context.RunNumber>1
It's just like having multiple output flows from a tMap, each with different expression filters.
One Star

Re: How to use Trigger Run If

I am getting a tJavaRow error

I think it's very unlikely you would want a RunIf directly from a tJavaRow. All flows are completed before a RunIf link is tested so if your RunIf expression depends on data in the flow, it will only be tested from the last row of the flow. If you do want your RunIf tested for each row of the flow, you would need to have a tFlowToIterate.
One Star

Re: How to use Trigger Run If

hi alevy,
Thanks for your quick responses and the caveat about the tJavaRow and Iterate.
Actually, I am only checking for one row in a file for the Run IF conditional so I should be ok without the Iterate. I do use the contents of the file later on for other purposes.

Thanks,
Four Stars

Re: How to use Trigger Run If

I think it's very unlikely you would want a RunIf directly from a tJavaRow. All flows are completed before a RunIf link is tested so if your RunIf expression depends on data in the flow, it will only be tested from the last row of the flow. If you do want your RunIf tested for each row of the flow, you would need to have a tFlowToIterate.

I have to say thank you for this Alevy Smiley Happy

Re: How to use Trigger Run If

.
One Star

Re: How to use Trigger Run If

I am getting a tJavaRow error

I think it's very unlikely you would want a RunIf directly from a tJavaRow.  All flows are completed before a RunIf link is tested so if your RunIf expression depends on data in the flow, it will only be tested from the last row of the flow.  If you do want your RunIf tested for each row of the flow, you would need to have a tFlowToIterate.

Alevy,
I have the exact situation you explained. I am reading a input redshift table for all the rows, and depending upon a column value each row has, i am triggering a new talend flow.
I am using tJavaRow (passing context variables) and my RunIf is only writing one record (as you correctely said), where do add tFlowToIterate to read all the rows and write ouputs accordingly?