Skip to Content
avatar image
Former Member

Implementing if then else condition

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 03, 2007 at 04:48 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 03, 2007 at 05:03 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 03, 2007 at 02:56 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 03, 2007 at 02:37 PM

    try like this

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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 03, 2007 at 02:58 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 03, 2007 at 02:42 PM

    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

    Add comment
    10|10000 characters needed characters exceeded