CMS Development

Bob2245
トップ投稿者 | Platinum Partner
トップ投稿者 | Platinum Partner

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?

0 いいね!
1件の承認済みベストアンサー
Teun
解決策
名誉エキスパート | Diamond Partner
名誉エキスパート | Diamond Partner

How to remove brackets in variables tied to multiselect properties?

解決

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(']', '') }}

 

 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


元の投稿で解決策を見る

4件の返信
Teun
解決策
名誉エキスパート | Diamond Partner
名誉エキスパート | Diamond Partner

How to remove brackets in variables tied to multiselect properties?

解決

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(']', '') }}

 

 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


Bob2245
トップ投稿者 | Platinum Partner
トップ投稿者 | Platinum Partner

How to remove brackets in variables tied to multiselect properties?

解決

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

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

 

0 いいね!
Teun
名誉エキスパート | Diamond Partner
名誉エキスパート | Diamond Partner

How to remove brackets in variables tied to multiselect properties?

解決

Awesome! Sorry for the typo.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 いいね!
piersg
キーアドバイザー

How to remove brackets in variables tied to multiselect properties?

解決

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>
0 いいね!