How to remove brackets in variables tied to multiselect properties?

So, I’ve created a module that pulls in CRM data based on an ID provided by the content marketer editing the module. This pulling happens like so:

{% set crmProductQuery = "cxs_candidate_id=" + module.product_crm_id %}
{% set crmProductFields = "huidige_functietitel,opleidingsniveau,provincie,werkervaring,gewenste_uren_per_week" %}
{% set product = crm_object('cv', crmProductQuery, crmProductFields, true) %}

Where the field “opleidingsniveau” is a multiselect property with 3 options: MBO, HBO, WO.

This field is placed in the HTML code like so:

<p style="mso-line-height-rule:exactly; line-height:175%; text-align:left" align="left">{{ product.opleidingsniveau }}</p>

The result is that it renders like so in my emails:

Bob2245_0-1630396459867.png

As you can see, these brackets get added around the options array. They’re not part of the field value, I checked.

Is there any way to strip those brackets from the rendered html?

It’s returning an array so you should loop over it to get each individual item

<p style="mso-line-height-rule:exactly; line-height:175%; text-align:left" align="left">{% for item in product.opleidingsniveau %}{{ item }}{% unless loop.last %}, {% endunless %}{% endfor %}</p>

Hi @Bob2245 ,

Could you check the output of the following:

{{ product.opleidingsniveau|pprint }}

It should show if this is a string or an array.

If it is an array, you could use the following:

{{ product.opleidingsniveau|join(', ') }}

If it is a string (which would be odd), you could do the following:

{{ product.opleidingsniveau|replace('[', '')|replace(']', '') }}

@Teun thanks! Second one fixed it, but I had to take out one of the )'s. So this did it:

{{ product.opleidingsniveau|join(', ') }}

Awesome! Sorry for the typo.