Genesys Cloud - Main

 View Only

Sign Up

  • 1.  Help with Data Action configuration - Arrays and Objects

    Posted 6 days ago

    I am building a custom data action for a customer's external application. The data action sends an input and retrieves customer details from the application. Part of the output includes a "Dates" object which contains an array of dates which include contract start date, contract end date, and customer date of birth. The issue I have is some records don't include the date of birth which is causing my action to fail in some cases. The date of birth is the only value from the array that I need for my inbound flow.

    This is an example of the output:

    "Dates": {
                "Date": [
                    {
                        "Type": "CONTRACT_START_DATE",
                        "Value": 20240110
                    },
                    {
                        "Type": "CONTRACT_END_DATE",
                        "Value": 20280109
                    },
                    {
                        "Type": "MONTHLY_PAYMENT_DUE_DATE",
                        "Value": 20260309
                    },
                    {
                        "Type": "LAST_PAYMENT_DATE",
                        "Value": 20260209
                    },
                    {
                        "Type": "DATE_OF_BIRTH",
                        "Value": 19510805
                    }
                ]
            },
    I have the the Date of Birth configured as an integer contract for my outputs. In my translation map it is conifgured like this:
    "ArrayDateOfBirth": "$.Dates.Date[?(@.Type=='DATE_OF_BIRTH')].Value",
    My success template is configured like this: 
    \"DateOfBirth\":${successTemplateUtils.firstFromArray(\"${ArrayDateOfBirth}\")}
    How can I configure my data action to still run successfully, even if the date of birth value is not present in the Date array? I'm guessing I can use the Translation Map Defaults but I am struggling to get this working for the array.

    #API/Integrations
    #ArchitectandDesign
    #Implementation

    ------------------------------
    James Foster
    Technical Consultant
    ------------------------------


  • 2.  RE: Help with Data Action configuration - Arrays and Objects

    Posted 5 days ago
    Edited by Christoph Domaschke 5 days ago

    Hi James,

    maybe I do not understand your question correctly. If so, please provide exact infos, what you want to achieve.

    The data action should work even if some "date of birth" are missing. The action only failes if there is no date of birth in not a single of your date-objects. For that case you need to configure the "translationMapDefaults" correctly.

      "translationMapDefaults": {
        "ArrayDateOfBirth": "[]"
      }
    This will write an empty array into your result. My example is working with a string-array. Maybe the "[]" will not work and [] without " will? Never did an integer-array before.



    ------------------------------
    Christoph Domaschke
    Produktmanager Kunden-Dialog-Center
    ------------------------------



  • 3.  RE: Help with Data Action configuration - Arrays and Objects

    Posted 5 days ago

    Hi James,

    I found it so much easier to create a data action where the output is a string containing all the API result. Then within the Architect convert it into JSON and run all the available JSON command to arrive at the data I need.

    Regards



    ------------------------------
    Vineet Kakroo
    Senior Technical Consultant
    ------------------------------



  • 4.  RE: Help with Data Action configuration - Arrays and Objects
    Best Answer

    Posted 5 days ago

    If you go to the Contracts > Output contracts > ArrayDateOfBirth, then expand the parameters to edit the attribute properties and constraints.  There is a "default value" field where you can set it to "0".  I don't believe you can use a "null" or \"null\" default value for an integer, but it maybe worth a try.  If you don't want to use the default value, then make sure the "required" parameter is set to "not required".



    ------------------------------
    Carlos Albor
    Principal PS Consultant
    ------------------------------



  • 5.  RE: Help with Data Action configuration - Arrays and Objects

    Posted 4 days ago

    Use the translationMapDefault to set some value that is known within the flow to mean "it wasn't returned".  The default value will only be used if the jsonPath doesn't resolve to something.   In your case, you could use something like 000000; then within the flow you can do a quick validation of the value returned from the data action to determine if there's useful information in there and differentiate the behavior within the flow based on the result.  



    ------------------------------
    Richard Schott
    Product Manager
    ------------------------------