custom variable doesn't work in query for the crm_objects

I am trying to set a custom variable that is set in a workflow to be able to add to the query for the crm_objects, but it seems to not work.

If I add the static value that is being pulled it works.

For example: limit=3&hs_images__not_null&uc_product_type__contains=Area Rug

But if I try to dynamically add it like below it dosn’t work:

{% set crm_products = crm_objects(“product”, “limit=3&hs_images__not_null&uc_product_type__contains=”~custom.product_type, “hs_images,hs_url,name”) %}

Anyone know why?

Hi @KenyonKowal,

I would suggest checking to see if a value is getting passed through the “custom.product_type” in the first place.

For example:

{% set c_product_type = custom.product_type %}

<p>Custom product type: {{ c_product_type }}</p>

{% set crm_products = crm_objects("product", "limit=3&hs_images__not_null&uc_product_type__contains="~c_product_type, "hs_images,hs_url,name") %}

I don’t know the exact mechanism behind this but on a few occassions I noticed that setting the variable separately beforehand and using that in the query param can resolve issues like this.

However, if nothing is showing up after the “Custom product type:” text in the example, then the context in which the “custom.product_type” property itself is being used would likely be the issue.

Hope this helps!

Hey, thanks for the reply. Yes unfortunately I did try that (setting a variable, as well as setting the value to make sure it’s being outputted). Both were true and did not work.

I am able to get the right data in the email if the string is completely static. The output string in the email is exactly the same.

"limit=3&hs_images__not_null&uc_product_type__contains=Area Rug"

Just seems to be an issue with it being dynamically loaded.