cancel
Showing results for 
Search instead for 
Did you mean: 

Implementing if then else condition

Former Member
0 Kudos

Hi! All

It would be very helpful if i can get answer of how to implement the condition below, using the functions available in graphical mapping editor....

I need to map 2 source fields to 1 Target field, based on the condition that field(source) is populated in the target field only if field 1 is null.

Source----->Target

part_id1----


>part_num(if part_id1 is null,then part_id2)

part_id2----


>

I tried using if then else function, it is working fine but errors out when part_id is null....need to make it work even when part_id1 or part_id2 is null.If both fields are null it should not populate anything.The boolean function is not accepting null inputs...

Please, let me know if there is a better way to implement this logic...Thanks a lot!

Regards,

Patrick

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Jones,

Have this logic in your mapping:

part_id1>exists>and

part_id1>equals(textfunction)>null(take constant and dont put any value in it)>equals(text funciton)>false

Give the above two to if

Then in the then part give part_id1 and in the else part give part_id2.

So in the above if part_id1 exists and equals to null then part_id2 will be output and part_id1 exists and not equals to null then part_id1 will be the output and part_id1 doesnot exist then part_id2 will be the output.

Regards,

---Satish

Answers (5)

Answers (5)

justin_santhanam
Active Contributor
0 Kudos

Patrick,

What u are referring here as null? Please tell on which condition u want to choose part_id2

Please see the below conditions for part_id1

part_id1 -


> Empty

part_id1 -


> null

part_id1 -


> doeesn't exist from source.

Which conditions u will choose!!

best regards,

raj.

Former Member
0 Kudos

Hi! Raj

I want to choose part_id2 when any of the 3 conditions you have mentioned is true and if part_id2 is also empty or null then nothing

should be populated in part_number.

3-conditions

part_id1 -


> Empty -or-

part_id1 -


> null -or-

part_id1 -


> doesn't exist from source.

Thank you,

Patrick.

Former Member
0 Kudos

Patric,

You can try function "Exists" which check for whether input value is empty or not...

Nilesh

Former Member
0 Kudos

change the occurrence of the target field to 0...1

Former Member
0 Kudos

Patric,

I think best and simplest way would be to write a UDF. You can take both source fields as a input to your UDF. Also before assigning source to UDF check for empty.

Process data as per your requirement and conditions.

Then you can result output to target field using result.addValue("Your Value ")

Let me know if you needmore details.

Nilesh

Former Member
0 Kudos

Hi Jones,

For you problem, Use the EXIST Node function, follow the following logic

part_id1->Exist->IF then part_id1

else part_id2

This will definelty workout.

Warm Regards,

Vijay

former_member184619
Active Contributor
0 Kudos

Hi Patrick,

Try using the standard Node Function

<b>CreateIF</b>

check this for details on how to use

/people/sravya.talanki2/blog/2005/12/08/message-mapping-simplified-150-part-ii

Sachin

Former Member
0 Kudos

try like this

Source---Map with default(Null value)-Target