[resolved] tMap & Conditions Problems (conversion)

Highlighted
One Star

[resolved] tMap & Conditions Problems (conversion)

Hello everybody,
I'm beginner on Talend Open Studio for Big Data, i use it for integrate AS400 data's to Prestashop database.

My problem is the following :
I have two table and i have a problem with my condition (cf : screenshot)
This is my condition :
row1.CLITPR!="*"?Import_as400_presta.id_default_group=="2":Import_as400_presta.id_default_group=="1"

When i execute i have the following problem :
Impossible to convert boolean to String !
But i made exactly as i saw on differents forums !
Help me please !
Thank you !

Accepted Solutions
Moderator

Re: [resolved] tMap & Conditions Problems (conversion)

Hi,
You should use row1.CLITPR.equals("*")?"1":"2" without Import_as400_presta.id_default_group. It is just an example to make the String result "true" or "false" more clear.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

All Replies
Moderator

Re: [resolved] tMap & Conditions Problems (conversion)

Hi,
It is ternary if-else operator in tMap. Condition?value if true: value if false
E.g.
(row1.name == null) ? "true"(value) : "false"(row1.name) returns the String "true" or "false" based on a Boolean value.
row1.CLITPR!="*"?Import_as400_presta.id_default_group=="2":Import_as400_presta.id_default_group=="1"

Could you please tell us more about your use case?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: [resolved] tMap & Conditions Problems (conversion)

Hi,
Thank you for your answer !
I want this result in the case default_group :
row1.CLITPR!="*"?Import_as400_presta.id_default_group=="2":Import_as400_presta.id_default_group=="1"
To summarize: if CLITPR is different to "*" then the default group is "2" else the default group is "1"
The result of the second table depends on the value of the primary table .
Do you know what i mean ?

Thank you Sabrina
Moderator

Re: [resolved] tMap & Conditions Problems (conversion)

Hi,
If I understand you well, you can use expression as:
row1.CLITPR.equals("*")?"Import_as400_presta.id_default_group==1":"Import_as400_presta.id_default_group==2"
The result will return the String "true" or "false" based on a Boolean value.

Let me know if it is OK with you.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: [resolved] tMap & Conditions Problems (conversion)

Hi,
I have already used this solution !
My needs are :
The result will return the String "1" or "2" in the case default_group and not a boolean.
Let me know if it is OK with you Sabrina Smiley Happy
Moderator

Re: [resolved] tMap & Conditions Problems (conversion)

Hi,
You should use row1.CLITPR.equals("*")?"1":"2" without Import_as400_presta.id_default_group. It is just an example to make the String result "true" or "false" more clear.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: [resolved] tMap & Conditions Problems (conversion)

Oh God IT WORKS !
Thank You Sabrina !

I love Youuuuuuuuuuuuuuuuu! Smiley Happy
Moderator

Re: [resolved] tMap & Conditions Problems (conversion)

Hi,
Glad you could solve the issue. Could you click the "Set this topic as Resolved"?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Download