You are not logged in.

Unanswered posts



Important! This site has been replaced. All content here is read-only. Please visit our brand-new community at https://community.talend.com/. We look forward to hearing from you there!



#1 2017-03-30 17:33:22

fathiben1
Member
6 posts

fathiben1 said:

tMap var with 3 context

Hello,
   I am a casual user of Talend, I encounter the following problem:
   Let 3 be the input variable
   Var program = 1
   Var program = 2
   Var program = 3
   With 3 context talend
   Context A, Context B, Context C.
I want to associate each corresponding record of my input file with this or that type of record.
If
    Var.Program == 1, context A
     Else
    Var program == 2 context B
    Else
   Var program == 3 context C
I try to use the ternary notation: as follows
(Var.Program == 1)? Context.A: (Var.Program == 2? Context.B: (Var.Program == 3? Context.C: null))

But it does not work, I missed something?

Thank you for your help

Offline

#2 2017-03-31 09:11:02

TRF
Member
388 posts

TRF said:

Re: tMap var with 3 context

Hi,
Where does Var.Program come from? Is it a variable defined in tMap?
What doesn't work?

Regards,
TRF

Offline

#3 2017-03-31 10:28:19

fathiben1
Member
6 posts

fathiben1 said:

Re: tMap var with 3 context

Hi TRF 
This condition 
(Var.Program == 1)? Context.A: (Var.Program == 2? Context.B: (Var.Program == 3? Context.C: null))
for In any case I receive a value null for may RecordTypeId
yes var program it's defined in tMap


it's work fine if i have 2 condition : (Var.Programme == 1 || Var.Programme == 2 ) ? context.salesforce_rt_account : context.salesforce_rt2_account 
but not for 3 condition 


Regards 
Fathiben

Last edited by fathiben1 (2017-03-31 10:38:18)

Offline

#4 2017-03-31 10:30:33

fathiben1
Member
6 posts

fathiben1 said:

Re: tMap var with 3 context

my screenshot mini_blob_20170331-0231.png

Last edited by fathiben1 (2017-03-31 10:35:02)

Offline

#5 2017-03-31 12:41:38

TRF
Member
388 posts

TRF said:

Re: tMap var with 3 context

What if you remove all brackets?

Offline

#6 2017-03-31 13:41:40

fathiben1
Member
6 posts

fathiben1 said:

Re: tMap var with 3 context

The recordings are inserted but not with a recordtype  
context.salesforce_rt_account ,context.salesforce_rt2_account   or  context.salesforce_rt3_account  

Offline

#7 2017-03-31 13:49:53

vapukov
Member
470 posts

vapukov said:

Re: tMap var with 3 context

Think You need remove round brackets - ()
? logic perfect work without them:


Var.Program == 1? Context.A
: Var.Program == 2? Context.B
: Var.Program == 3 Context.C
: null

must work, till You not have == 4, or "NaN" or "Infinite" from Var.Program

Last edited by vapukov (2017-03-31 13:51:56)

Offline

#8 2017-03-31 14:18:38

TRF
Member
388 posts

TRF said:

Re: tMap var with 3 context

Well, I suppose your context variable contain Salesforce RecordType Ids. This is not a good practice.
Prefer to store the developerName field value (more readable), then Select the Id from the RT with developerName and store it into a global variables you'll use to populate the recordTypeId field.
For your problem, what is the next step after the tMap?

Offline

#9 2017-03-31 14:42:17

fathiben1
Member
6 posts

fathiben1 said:

Re: tMap var with 3 context

TRF ,

I don't have the next step after the tMap ,  
I just want to put that in place

programme 1 ---> context.salesforce_rt_account --> société 1 

programme 2 ---> context.salesforce_rt2_account --> société 2

programme 3 ---> context.salesforce_rt3_account --> société 3 


if i have 2 condition it's work fine 
(Var.Programme == 1 || Var.Programme == 2 ) ? context.salesforce_rt_account : context.salesforce_rt2_account 





(Var.Programme == 2 || Var.Programme == 3 ) ? context.salesforce_rt2_account : context.salesforce_rt3_account 


but not with 3 condition 
 

Offline

#10 2017-03-31 16:03:48

cterenzi
Member
93 posts

cterenzi said:

Re: tMap var with 3 context

A ternary operator works like this:
CONDITIONAL ? valueIfTrue : valueIfFalse

The 2 conditions in your last post essentially say, "If Var.Programme is 1 OR 2 then output context.salesforce_rt_account, otherwise output context.salesforce_rt2_account"

To handle three conditions with ternary operators requires nesting them. Vapukov's example covers what you're describing.

Offline

Board footer

Talend Contributor Agreement - Talend Website Privacy Policy