CMS Development

KenyonKowal
Participant

custom variable doesn't work in query for the crm_objects

SOLVE

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?

0 Upvotes
1 Accepted solution
evaldas
Solution
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

custom variable doesn't work in query for the crm_objects

SOLVE

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!


✔️ Did this post help answer your query? Help the community by marking it as a solution.

View solution in original post

2 Replies 2
evaldas
Solution
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

custom variable doesn't work in query for the crm_objects

SOLVE

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!


✔️ Did this post help answer your query? Help the community by marking it as a solution.

KenyonKowal
Participant

custom variable doesn't work in query for the crm_objects

SOLVE

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.

0 Upvotes