Customer Portal

conditional string replacement

Comments 3

  • Avatar
    simaj
    0
    Comment actions Permalink
    Hi Aronax,

    The clause you are trying to carry out is correct, what is missing is the output port that is mandatory if you want to forward the result to the next component :


    function integer transform() {

    if(length($in.0.Month) == 6) {

    $out.0.Month=replace($in.0.Month, "/", "0");

    }
    else

    $out.0.Month=replace($in.0.Month, "/", "");

    return ALL;
    }


    Please note that the Clover you are currently using is obsolete and is no longer supported, I suggest to upgrade to the newest version 4.0.4 .
  • Avatar
    aronax
    0
    Comment actions Permalink
    Hi & thanks for the reply,

    So can I add this function code in the transformation component?

    found a workaround...maybe someone else can benefit... :

    iif(isnull($in.0.Month),"null",iif(length($in.0.Month) == 6,replace($in.0.Month, "/", "0"),replace($in.0.Month, "/", "")))


    it's not by choice I use this version... it is the latest version we can use at the moment...

    Thanks again,
    Aronax
  • Avatar
    simaj
    0
    Comment actions Permalink
    Yes, you can use both codes in the transformation component as you have probably already tested. Just reminding that you have to specify the output port and metadata field.



    $out.0.Month = iif(isnull($in.0.Month),"null",iif(length($in.0.Month) == 6,replace($in.0.Month, "/", "0"),replace($in.0.Month, "/", "")))

Please sign in to leave a comment.