Talend If in Tmap

Highlighted
Five Stars

Talend If in Tmap

Hello, 

I have condition where doing insert in Salesforce.

If field1= 'CHQ' then FinalDate = date1

else if field1 = 'CB' then FinalDate = Date2 

 

In Salesforce, field is null

Can SomeOne Help me.


Accepted Solutions
Seven Stars

Re: Talend If in Tmap

Hello aichas,

 

your code in the attached GIF is almost correct. Please do not use "==" for comparing strings, use the .equals() method.

((row4.TypeCoupon.equals("CHQ") ? row4.DateCheque : row4.DateDignature))

For your example given in the text, you can nest such ternary statements. The formula for "FinalDate" could be

field1.equals("CHQ") ? date1 : field1.equals("CB") ? Date2 : date3

"date3" is the value for "FinalDate" if field1 is not equal to "CHQ" or "CB".

 

Best regards,

 

Thomas

 


All Replies
Seven Stars

Re: Talend If in Tmap

Hello aichas,

 

your code in the attached GIF is almost correct. Please do not use "==" for comparing strings, use the .equals() method.

((row4.TypeCoupon.equals("CHQ") ? row4.DateCheque : row4.DateDignature))

For your example given in the text, you can nest such ternary statements. The formula for "FinalDate" could be

field1.equals("CHQ") ? date1 : field1.equals("CB") ? Date2 : date3

"date3" is the value for "FinalDate" if field1 is not equal to "CHQ" or "CB".

 

Best regards,

 

Thomas

 

Nine Stars

Re: Talend If in Tmap

Hi,
just a small tip. Instead of using this:

field1.equals("CHQ")

use that:

"CHQ".equals(field1)

And you won't have NullPointerException anymore when field1 is null Smiley Wink

Regards

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Download