"is containing" does not seem to work when looking at list memberships


#1

I have failed. Looking to smarter people than me for help.

{% set numbers = [1, 2, 3] %}

{% if numbers is containing 2 %}
Set contains 2!
{% endif %}

This works fine. {{ numbers }} would print [1, 2, 3]

When I use the same expression for List Membership however it does not work.

{% if request.contact.list_memberships is containing 5 %}
You Are Registered
{% else %}
You Are Not Registered
{% endif %}

{{ request.contact.list_memberships }} would print [1, 3, 5, 99]

Any suggestions?


#2

Hi @JonSasala, can you link to the page or module you're working on here? Happy to take a look. From a quick glance, I don't know if the request object is something that HubL can read. Also, the list_memberships property needs to be a contact property in your account for this to work


#4

Hi @Connor_Barley . Thanks for your response.

list_membership is not a contact property that we created. It is a default HubSpot contact property that shows the lists, by number, a user is a member of.

When viewing Developer Info it appears like this (for me) on the site I am working on (www.exo.works):

48%20PM

///

{% if request.contact.list_memberships %} This Works! {% endif %}

and I can see that {{ request.contact.list_memberships }} prints [130, 131, 5, 133, 6, 8]

{% if request.contact.list_memberships is containing 5 %} ... {% else %} This Does Not {% endif %}

///

I created a Testing Module here if you can access it. https://app.hubspot.com/beta-design-manager/3289821/modules/6675021283

Thanks again!


#5

Hey @JonSasala, how are you testing this? Are you previewing the page as a particular contact? If not, there wouldn't be a way for HubSpot to compare the contact to list_memberships. If you don't know how to preview as a particular contact, Command + F for "preview as" in this article: https://knowledge.hubspot.com/articles/kcs_article/cos-general/how-to-use-personalization-with-your-content.

If that doesn't work, would you be able to link a test page this module is on so I can take a look at the dev info myself and test some things?

Have a great weekend!


#6

How am I testing this: I am viewing the module on a published page and I am a contact in the database.

If I place {{ request.contact.list_memberships }} on a page and view that page, it will show me, and all visitors, data based on the cookied device the visitor is on. Users who are on any lists will see something like [1, 2, 3]. Users who are unknown would see [  ].

If you view any HubSpot hosted page and look at Developer Info it shows all available data HubSpot has available. When I view that it will show data related to my contact record.

///

I have added the test widget here: https://www.exo.works/custom-module-test


#7

Hi @JonSasala, Got it -- I was able to reproduce this. I wonder if the issue has to do with the timing of when the cookie that identifies the contact and when Hubl evaluates the if statement. I'm going to reach out to my team regarding this and I'll let you know what I find!


#8

Is there a HubL expression that can be manually used to replicate smart content that is based on list membership?


#9

Hey @JonSasala, I'm still working on this issue, but we haven't determined if this expression test doesn't work for the list membership field on purpose or not. While I'm working internally with my team on this, I actually think it would be a great question to post to our CMS developer slack channel. You can get started here: https://designers.hubspot.com/discoverykit?hsCtaTracking=7e8fadce-f737-4f71-a160-cd9fbf93ea6b|7bc2f369-ac73-4a93-9fc8-ea63d7ccf078


#10

Hey @JonSasala, it looks like the request_contact.list_memberships variable is a java hashset (which is iterable, but not filterable) rather than a Pylist, which is what a hubl array produces.

The team is working on a fix for this one!


#11

Thanks Connor. I have put this out to the Slack channel and continue to look for alternative ways to change info based on list membership. Looking forward to any fix you may find.


#12

No worries @JonSasala, the engineering team is pushing out a fix soon. I'll check in to see what the status if that is.


#13

Hey @JonSasala, we just pushed out a fix. I'm seeing it work for me on a test page now. Can you confirm it works on your end?


#14

Connor, I can confirm this is now working. Thank you!

{% if request.contact.list_memberships is containing 5 %}
You Are Registered
{% else %}
You Are Not Registered, even though these are the lists you are on: {{ request.contact.list_memberships }}
{% endif %}

The fix that was pushed out, can you tell us a bit more about what it achieved? Was it unique to the List Membership property or all java hashset properties?


#15

Hi @JonSasala I believe this applies to all java hashsets: "JinJava parses a literal number to Long. When testing equality, a Long is not equal to an Integer."