Data Action from Agent Script and Reading Arrays

Hi,

I want to call a data action directly from an agent script and process a response that contains an array.

However when I add the data action to the script and tie it to a button the Inputs/Outputs do not display.

If I remove the array from the data action the Input/Output fields show.

Data Action Export: DataLookup-20201016171451.custom.json (1.2 KB)

Response:
{
"name": "name",
"data": [
"string1",
"string1"
],
"total": 10
}

Is this a limitation of the system or am I doing something wrong?

Thanks,
Darren

The issue is that your output contract has two item's in the items array. This is an array of strings, so you only need to have one string configured in the items array, which will allow any number of strings to be returned in that array.

--Jason

@Jason_Mathison thank you for the quick reply. That did the trick but I'm unable to assign that field a variable.

I've tried creating different variable types but doesn't let me select. If I click "Create New Variable" it opens a dynamic string option.

I know in architect we can access items in an array by appending 'variableName[n]' where 'n' is the index value in the array.

Can I achieve something similar in a agent script?

Edit:

I think I have found the answer this question here: https://help.mypurecloud.com/articles/look-data-external-source/

"Data returned to a script from a data action must be in a compatible format. Currently, scripts cannot read data from a JSON array. Some fields returned from Data Dip connectors may currently be inaccessible."

I'd still be interested in if I can pass all the data into one string eg: ("string1, string1")

Thanks,
Darren

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