Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  DataAction remove duplicate value in Array output

    Posted 17 days ago
    Edited by Jeremy Monzo 17 days ago

    Hello,

    I would like remove the duplicated value in a array defined in output data action.

    For example, if the output is ["apple","banana","apple"] I would like keep ["apple","banana"].

    {"translationMap": {"queueName": "$.participants[?(@.purpose == 'acd')].queueName"},"translationMapDefaults": {"queueName": "[]"},
    "successTemplate": "{\n   \"queueName\": ${queueName}\n}"}
    I try using velocity approach but cannot use complex feature (ex : #foreach). Is there a way to achieve the result in data action  or must use data action + architect for achieve this?
    thanks


    #DataActions

    ------------------------------
    Jeremy
    ------------------------------



  • 2.  RE: DataAction remove duplicate value in Array output

    Posted 16 days ago

    Hi Jeremy Monzo,

    Yes,  the simplest approach is to handle it in Architect (remove duplicates after you receive the array).

    If you only need a specific value (for example, the first item from the array), you can use:
    firstFromArray ${successTemplateUtils.firstFromArray(\"${ids}\", \"{}\")}

    Alternatively, you can also solve it using Data Actions Function (by implementing a function to return a distinct list) and return the array already deduplicated: https://help.mypurecloud.com/articles/about-the-genesys-cloud-function-data-actions-integration/

    Hope it helps.



    ------------------------------
    Luiz Rosa
    Full stack developer
    ------------------------------



  • 3.  RE: DataAction remove duplicate value in Array output

    Posted 14 days ago

    Hi Luiz,

    Thanks for feedback. 

    My goal is to uses only a simple data action without AWS Lambda code or Architect but seem difficult.

    BR

    jeremy



    ------------------------------
    Jeremy
    ------------------------------