Talend If in Tmap

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

 

View solution in original post


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

 

View solution in original post

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

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog