Remove duplicate value from transform

Hi,
I have an output from a transform which is a string of numbers deliminated by a semi-colon. Sometime due to the source data, there is a duplicate value.
eg: 1234;2345;4567;1234
How can I remove the duplicate to leave: 1234;2345;4567

The duplicate is causing problems when it is sent to a third party software. The duplicate cannot be removed by them, nor by the source data.
Many thanks, and season greetings

Phil

Hi @PhilRawlings

You can use below Transform.

{
    "name": "Duplicate Static Transform",
    "type": "static",
    "attributes": {
        "data": {
            "attributes": {
               "attributeName": "attName",
               "sourceName": "sourceName",
            },
            "type": "accountAttribute"
        },
        "value": "#set($uniqueValues = [])#foreach($value in $data.split(';'))#if(!$uniqueValues.contains($value))#if($uniqueValues.add($value))#end#end#end#set($resultString = \"\")#foreach($element in $uniqueValues)#if($foreach.hasNext)#set($resultString = \"${resultString}${element};\")#else#set($resultString = \"${resultString}${element}\")#end#end$resultString"
    },
    "internal": false
}

Brilliant,
I’ll check that out tomorrow.
Thank you very much
Phil

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.