Skip to Content
avatar image
Former Member

Issue with the UDF in MM

Hi All,

I have trying to use a user defined function in the XI message mapping.

Here is the code of the User defined function :

if (a != null)

return "test";

else

return "fail";

The mapping looks like :

a -


> UDF -
> result.

If I am sending the tag for "a" ; I get the result as "test".

But I am fully avoiding the tag itself. ( not even the empty tag); I get the error saying " Cannot produce the target element ...result".

Can anyone help me in resolving the issue ?

"a" is defined as an optional field.

The above case is just a prototype for a big problem.

Good Day!!!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    Mar 10, 2008 at 03:50 PM

    Hi,

    You don't need UDF for this, you can do it with below logic.

    a -


    > exists -


    > If then else -


    >Target.

    then branch -


    > Constant(Test)

    else branch -


    > Constant(Fail)

    raj.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      use mapwithdefault node function before the UDF

      a >mapwithdefault >UDF-->result

      use this in udf

      if(!a.equals(""))

      {

      return "test"' ;

      }

      else

      {

      return "fail";

      }

      or insted of UDF

      here is what you will have

      a >mapwithdefault >equals(Function from Text) to "" --> Bolean function if --> if conditoin is true then send fail else test

      Edited by: Pramod Yadav on Mar 13, 2008 3:13 AM

  • avatar image
    Former Member
    Mar 13, 2008 at 03:03 AM

    Peeru,

    The reason why you are not getting the 'result' tag when you avoid the 'a' tag is because in this case the UDF would not be executed.

    So, I think that as pointed out by Raj the 'exists' function would be of more help here.

    Thanks,

    Anand

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 13, 2008 at 04:34 AM

    you can use collapsContext and malke your if condition as

    if(!a.equals(""))

    .

    .

    .

    .

    .

    or u can put your if condition As(if you do not wish to use Collaps Context)

    if(!a.length() == 0)

    .

    .

    Reward Points if Helpful

    Thanks

    Sunil Singh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 10, 2008 at 03:43 PM

    PI Developer..

    You should not be doing..if (a != null) when "a" is defined as an optional field.

    You should be using that if..a is a mandatory field and to check if it was being populated..

    Regards

    Ravi Raman

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks Ravi for your response.

      What if we have to use the UDF when "a" comes ? and "a" is optional too.

      Peeru

  • avatar image
    Former Member
    Mar 13, 2008 at 03:55 AM

    Hi

    use the UDF in the following way.

    if(!a.equals(""));

    {

    return("test")

    }

    else

    {

    return("fail");

    }

    if u r getting the error as "Cannot produce the target element ...result"

    then check the occurence for the target field whether the filed is mandatory or not.

    if it's occurence is 1..1 then u have to map this filed with some source filed.

    Thanks

    Rinku

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 13, 2008 at 03:34 PM

    .

    Add comment
    10|10000 characters needed characters exceeded