tHMap how to used the function IfThenElse

Highlighted
Five Stars

tHMap how to used the function IfThenElse

Hi, 

I want to transform json to xml and i have in the json file a string column can contain two value : SERVICE or PRODUCT.

So in the component tHMap i want to use the function IfThenElse to put un the xml file true or false :

If ColumnValue=SERVICE then True else False.

tHmap.png

The condition don't accept to write a code, it accept just drop/paste !!!!

 

Thanks.

 


Accepted Solutions
Highlighted
Community Manager

Re: tHMap how to used the function IfThenElse

Here is an example with a dummy schema that I had on my machine....

Screenshot 2019-11-21 at 14.16.06.png

Notice I dragged the "EQUAL" method from the Functions menu. I then added my value to the first field and dragged the "CONSTANT" function to the second. I then was able to type "SERVICE" as the "CONSTANT" value. Below you can add your THEN and ELSE options.

View solution in original post


All Replies
Highlighted
Community Manager

Re: tHMap how to used the function IfThenElse

Here is an example with a dummy schema that I had on my machine....

Screenshot 2019-11-21 at 14.16.06.png

Notice I dragged the "EQUAL" method from the Functions menu. I then added my value to the first field and dragged the "CONSTANT" function to the second. I then was able to type "SERVICE" as the "CONSTANT" value. Below you can add your THEN and ELSE options.

View solution in original post

Highlighted
Five Stars

Re: tHMap how to used the function IfThenElse

i used this solution but i have always false Smiley Sad 

i think something else it missing

Highlighted
Community Manager

Re: tHMap how to used the function IfThenElse

You will need to check the data that is being compared. For example, what case is it, does it have spaces after the value, etc

Highlighted
Five Stars

Re: tHMap how to used the function IfThenElse

yes it's a problem of data.

Thanks.

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

Best Practices for Using Context Variables with Talend – Part 3

Read about some useful Context Variable ideas

Blog