1

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.

enter image description here

1 Answer 1

2

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.

Output from FreeMarker for Transformed List: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.