Using a programmable in a Sitecore Personalize decision model, I want to return a List but List is not an available type in the dropdown.
1 Answer
It is not currently possible to output a List from a decision model, in the settings of a programmable ‘List’ is not one of the available output Types in the settings.
If a list is returned from a programmable it will be transformed into a Map as shown below.
List returned as Map from a decision model programmable:
"output": {
"0": "list1",
"1": "list2",
"2": "list3"
},
If you are using your decision model in a Full Stack experience, you can transform the Map output of your decision model back into a List using FreeMarker.
FreeMarker for transforming decision model Map into List:
{
"list": [
<#list MyObject?keys as key>
"${MyObject[key]}"<#sep>, </#sep>
</#list>
]
}
This FreeMarker snippet can also be seen in the snippets section on the right hand side when building an API Response or Webhook in a Full Stack Experience.