I'm not saying this is a great idea, but you could replace the comma with a similar looking unicode character. This could be OK for UI purposes, but would almost certainly cause issues if you ended up taking the output from this data action and tried storing it somewhere.
A search like this will give some options: "unicode characters that look like comma
Original Message:
Sent: 09-12-2025 08:16
From: Marcello Jabur
Subject: Displaying objects in a variable array in an agent script
Hi Tim,
I'm not sure if it's going to work, but I have an idea that you could try.
The main goal would be to replace the commas in the data action response (you would have to try this in the "Translation Map" section of the Data Action configuration.. Let's say for something like "@@@@", or anything else.
If you can do that, then you would have the correct indexes for each comment on your script.
Now you would have to reverse that, by replacing "@@@@" with commas in your Dynamic Variables in the script (which would already have each comment index in them).
---------------
To try to achieve the first part (Translation Map), I believe you can try using the ".replace()" function..
It should look something like this:
{
"translationMap": {
"commentBody": "$.comments[*].body"
},
"translationMapDefaults": {},
"successTemplate": "{\"commentBody\": ${commentBody.replace('\",\"', '\"@@@@"\')}}"
}
Keep in mind that the above is just a random example, I'm not sure how you are setting your translation map, but you could try to use the replace function to change those commas.
-----------
If the above works, then you get to the script and must reverse it.
I couldn't find a "Replace()" function for the scripts in the documentation, so I'm not sure if it exists.
But I noticed the Regex functions and believe they could work (I haven't tried it).
You can check the documentation for the Regex functions here: https://help.mypurecloud.com/articles/additional-functions-to-use-in-dynamic-variables/
But basically you have to match something, and then define what the function should return... I think you can probably find a way to match the "@@@@" and make it return comma in its place... But I'm not entirelly sure.
------------------------------
Marcello Jabur
Original Message:
Sent: 09-12-2025 04:38
From: Tim Speakman
Subject: Displaying objects in a variable array in an agent script
Hi Marcello,
This is exactly what I was after, thank you.
If I may add a follow-up question??
Many of the comments will contain a comma in the text, so the function is splitting the comments - so this:
"comments.body": [
"Just testing the Genesys/Zendesk ticket creation, this can be ignored",
"This is just a comment, one of many"
],
is creating the list variable as "Just testing the Genesys/Zendesk ticket creation, this can be ignored","This is just a comment, one of many".
But the function splits it as this:
Comment1: "Just testing the Genesys/Zendesk ticket creation
Comment2: this can be ignored"
Comment3: "This is just a comment
How do solve this, so it only indexes the array on the commas outside of each comment?
------------------------------
Tim Speakman
Tech Support Engineer
Original Message:
Sent: 09-11-2025 23:14
From: Marcello Jabur
Subject: Displaying objects in a variable array in an agent script
Hi Tim,
I'm not sure what exactly is your question, but regarding the way the response is shown in the Data Action, I always find it easier to take a look in the "Execute" step (I believe it's step 8 or maybe 7) on the Data Action testing page.
It should show the response in the same way you see it on Postman. So, as far as I know, the response is exactly the same you get from Postman, it just shows very differently when flattened.
----
Now, regarding showing that in a script... I believe it shouldn't be too hard, if I'm understanding you correctly.
You should create a few output variables in the output contract for the data you want to show... Those variables should be arrays.
In the script you will create List Variables, and map them to the outputs of your data action.
Then you can simply show each index from your list variable in the script.
To do that, create a Dynamic variable, and then you can use the getIndexValue(variable, index) function to set the value on that dynamic variable.
----
So, just to sumarize the steps, taking exactly what you want to show on the script:
1) You should map the Comments, Authors and Dates on the Output Contract of your Data Action as arrays.
2) You create 3 List variables in your script, and map the response from those outputs to your list variables.
3) You create 9 Dynamic variables (Comment 1, Comment 2, Comment 3..., Author 1-2-3.. Date 1-2-3), and use the getIndexValue function on those variables to extract the value from the necessary index.
4) You use the dynamic variables to show their values in the body of your script.
-------
Hope this helps!
------------------------------
Marcello Jabur
Original Message:
Sent: 09-11-2025 09:57
From: Tim Speakman
Subject: Displaying objects in a variable array in an agent script
Hi brainiacs,
I am implementing Zendesk Data Actions in our Genesys Cloud, with the aim of enabling an agent to create and lookup Zendesk tickets during a voice call, using an agent script.
The basics work fine but I need some help with pulling back ticket info into Genesys from Zendesk and displaying array objects in the script in a friendly format.
Below are the results of the 'Get Comments by Ticket Id' action and the same API using Postman. What I'd like to see is something like this:
Comments:
Written by comments.author_id[0] on comments.created_at[0]
comments.body[0]
Written by comments.author_id[1] on comments.created_at[1]
comments.body[1]
Written by comments.author_id[2] on comments.created_at[2]
comments.body[2]
(only last 3 max)
But the way Genesys flattens the output has me flummoxed on how to do it.
DATA ACTION
{
"comments.body": [
"Just testing the Genesys/Zendesk ticket creation.",
"this is just a comment"
],
"comments.public": [
true,
false
],
"comments.via.source.to.name": [
"Bob Dole",
null
],
"comments.plain_body": [
"Just testing the Genesys/Zendesk ticket creation.",
"this is just a comment"
],
"count": 2,
"comments.metadata.system.longitude": [
-6.2591,
-0.1409
],
"comments.metadata.system.client": [
"PureCloud-Data-Actions",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36"
],
"comments.via.channel": [
"api",
"web"
],
"comments.type": [
"Comment",
"Comment"
],
"comments.audit_id": [
30220907458077,
30250953163293
],
"comments.metadata.system.latitude": [
53.3382,
51.4615
],
"comments.via.source.to.address": [
"bob@bob.com",
null
],
"comments.html_body": [
"<div class=\"zd-comment\" dir=\"auto\"><p dir=\"auto\">Just testing the Genesys/Zendesk ticket creation.</p></div>",
"<div class=\"zd-comment\" dir=\"auto\">this is just a comment<br></div>"
],
"comments.metadata.system.location": [
"Dublin, L, Ireland",
"Lambeth, ENG, United Kingdom"
],
"comments.id": [
30220907458205,
30250953163421
],
"comments.metadata.system.ip_address": [
"52.50.233.109",
"137.83.244.161"
],
"comments.created_at": [
"2025-09-10T07:27:02Z",
"2025-09-11T07:54:47Z"
],
"comments.author_id": [
30192729890205,
30177981561629
]
}
POSTMAN
{
"comments": [
{
"id": 30220907458205,
"type": "Comment",
"author_id": 30192729890205,
"body": "Just testing the Genesys/Zendesk ticket creation.",
"html_body": "<div class=\"zd-comment\" dir=\"auto\"><p dir=\"auto\">Just testing the Genesys/Zendesk ticket creation.</p></div>",
"plain_body": "Just testing the Genesys/Zendesk ticket creation.",
"public": true,
"attachments": [],
"audit_id": 30220907458077,
"via": {
"channel": "api",
"source": {
"from": {},
"to": {
"address": "bob@bob.com",
"name": "Bob Dole"
},
"rel": null
}
},
"created_at": "2025-09-10T07:27:02Z",
"metadata": {
"system": {
"client": "PureCloud-Data-Actions",
"ip_address": "52.50.233.109",
"location": "Dublin, L, Ireland",
"latitude": 53.3382,
"longitude": -6.2591
},
"custom": {}
}
},
{
"id": 30250953163421,
"type": "Comment",
"author_id": 30177981561629,
"body": "this is just a comment",
"html_body": "<div class=\"zd-comment\" dir=\"auto\">this is just a comment<br></div>",
"plain_body": "this is just a comment",
"public": false,
"attachments": [],
"audit_id": 30250953163293,
"via": {
"channel": "web",
"source": {
"from": {},
"to": {},
"rel": null
}
},
"created_at": "2025-09-11T07:54:47Z",
"metadata": {
"system": {
"client": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36",
"ip_address": "137.83.244.161",
"location": "Lambeth, ENG, United Kingdom",
"latitude": 51.4615,
"longitude": -0.1409
},
"custom": {}
}
}
],
"next_page": null,
"previous_page": null,
"count": 2
}
#DataActions
#Scripts
------------------------------
Tim Speakman
Tech Support Engineer
------------------------------