Hi Walter,
DataActions are not my strong suite, yet.
But, the error is saying it was expecting a comma separated object (ie an array) in the success template.
Try this "successTemplate": "{\"surveyConsent\":${successTemplateUtils.firstFromArray(\"${Consent}\")}}"
Default would need updating too
Developer forum is a great place to check for tips on how to handle these, check this one out for handling defaults
https://developer.genesys.cloud/forum/t/translationmapdefaults-not-populating-missing-attributes/20176/2
Someone else might have a better solution.
------------------------------
Anton Vroon
------------------------------
Original Message:
Sent: 10-31-2023 16:52
From: Walter Ferguson
Subject: Web Survey using participant data
I went back and tried to update the data action so I just get the "surveyconsent" but am running into an error with my success template.
{
"translationMap": {
"Consent": "participants[3].attributes.surveyConsent"
},
"translationMapDefaults": {
"Consent": "No"
},
"successTemplate": "{\"surveyConsent\": \"${Consent}\"}"
}
Below is the error I am receiving.
Apply output transformation: Transform failed to process result using 'successTemplate' template due to error:'Unexpected character ('Y' (code 89)): was expecting comma to separate Object entries at [Source: (String)"{"surveyConsent": ""Yes""}"; line: 1, column: 22]' Template:'{"surveyConsent": "${Consent}"}'.
------------------------------
Walter Ferguson
Bridgecrest Acceptance Corporation
------------------------------
Original Message:
Sent: 10-30-2023 18:53
From: Anton Vroon
Subject: Web Survey using participant data
Hi Walter
From the screenshots it looks like that Success Output is returning an array (collection) of strings, not a single string value. So converting tostring on the array might not give you a simple yes / no. (The A has a box around it, indicating an array)
Try retrieving the first item in the array first, eg State.surveryconsent[0] == "yes" or find(state.surveryconsent, "yes") > -1 or GetAt(state.surveryconsent, 0) == "yes" Would pay to do a IsNotSetOrEmpty() check to ensure the list isn't empty beforehand as well.
Would also suggest you do some tests in the DataAction config area to ensure the data is coming through the way you expect, if you didn't want an array you will need to update the data action.
------------------------------
Anton Vroon