# custom variable doesn't work in query for the crm\_objects

**URL:** <https://community.hubspot.com/t/custom-variable-doesnt-work-in-query-for-the-crm-objects/128453>\
**Category:** CMS Development\
**Tags:** hubdb\
**Created:** [March 21, 2025, 8:30pm UTC](https://community.hubspot.com/t/custom-variable-doesnt-work-in-query-for-the-crm-objects/128453 "2025-03-21T20:30:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KenyonKowal](https://avatars.discourse-cdn.com/v4/letter/k/85f322/32.png) [@KenyonKowal](https://community.hubspot.com/u/KenyonKowal)\
**Post date:** [March 21, 2025, 8:30pm UTC](https://community.hubspot.com/t/custom-variable-doesnt-work-in-query-for-the-crm-objects/128453/1 "2025-03-21T20:30:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![evaldas](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/evaldas/32/69160_2.png) [@evaldas](https://community.hubspot.com/u/evaldas)\
**Post date:** [March 22, 2025, 5:40pm UTC](https://community.hubspot.com/t/custom-variable-doesnt-work-in-query-for-the-crm-objects/128453/2 "2025-03-22T17:40:47Z")

</div>

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:

```lia-code-sample
{% 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!

---

<div class="post-metadata">

**Author:** ![KenyonKowal](https://avatars.discourse-cdn.com/v4/letter/k/85f322/32.png) [@KenyonKowal](https://community.hubspot.com/u/KenyonKowal)\
**Post date:** [March 24, 2025, 3:22pm UTC](https://community.hubspot.com/t/custom-variable-doesnt-work-in-query-for-the-crm-objects/128453/3 "2025-03-24T15:22:58Z")

</div>

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.
