Customer Portal

How to merge two lists or dedup a list string in a reformat

Comments 2

  • Avatar
    Alex Donnelly
    1
    Comment actions Permalink

    Hi Michael,

    Just use Map (former Reformat) component. You can apply transformation similar to this one:

    //#CTL2
    string []lLicensedStates ;
    string []lLocationStates;

    // Transforms input record into output record.
    function integer transform() {
        
    //create lists of states from delimited input data
    lLicensedStates = $in.0.LicensedStates.split(";");
    lLocationStates = $in.0.LocationStates.split(";");

    //iterate through LocationStates and check for each state presence in LicensedStates list
    foreach (string state : lLocationStates){
        if (! state.in(lLicensedStates)){
            lLicensedStates.append(state);
        }
    }

    //convert list ot states into string, use ";" as delimiter
    string CombinedStates = join(";",lLicensedStates);

    $out.0.RecordID=$in.0.RecordID;
    $out.0.CombinedStates=CombinedStates;  

        return ALL;
    }

    It may not be the best performing way, but if your lists of states consit of only handful items, it will perform OK.

  • Avatar
    michaelj
    0
    Comment actions Permalink

    Thanks Alex.  That worked perfectly. 

Please sign in to leave a comment.