Google Tag Manager

Forum Discussion

Elysha-CT's avatar
Elysha-CT
Supporter
2 months ago

Help: Liquid logic, conditional messaging & nested custom attributes.

Hello! I need help understanding where i'm going wrong with my conditional messaging.

Is it possible to search and dynamically pull a specific value from a nested profile using Liquid code in a Braze email? 

Example: Users have a nested custom attribute called 'Colour'. User 1 is associated with two profiles: Company A (nested profile [0]) and Company B (nested profile [1]). The value of 'Colour' for Company A is 'Green', while for Company B it is 'Purple'. How can I dynamically retrieve the 'Colour' value for a specific company (e.g., Company A)? 

Note: I haven't used [] indexing as I want to look across all associated profiles per user to filter down for the correct value (example above). 

And the testing code:

{% assign found = false %}
{% for Partner_Name in custom_attribute.Profiles %}
  {% if Partner_Name == "Onsi" %}
    Your partner ID is {{custom_attribute.${Profiles}.Partner ID}}.
    {% assign found = true %}
  {% endif %}
{% endfor %}
{% unless found %}
  You do not have a partner ID associated with this account. 
{% endunless %}

Thank you for any help or suggestions you have!

  • Elysha-CTYour Liquid code actually looks exactly how we would approach it. The only thing we can point out is the syntax: 

    {% assign found = false %}
    {% for Partner_Name in {{custom_attribute.${Profiles}}} %}
      {% if Partner_Name == "Onsi" %}
        Your partner ID is {{custom_attribute.${Profiles}.Partner ID}}.
        {% assign found = true %}
      {% endif %}
    {% endfor %}
    {% unless found %}
      You do not have a partner ID associated with this account. 
    {% endunless %}
    Thank you for any help or suggestions you have!

    Your syntax in line 2, custom_attribute.Profiles, might be the only issue actually. 

    Let us know if this worked! 

    • Elysha-CT's avatar
      Elysha-CT
      Supporter

      Hi Allan, thanks for your help! Your corrected code means I'm not receiving any error codes, however Braze doesn't seem to recognise/pull in any values associated with nested profiles. I've brought this up to Braze Support; again thank you for your help!

      • AllanHeoFNM's avatar
        AllanHeoFNM
        Visionary

        Please keep us posted! There's a bit more we'd have to see to be able to help troubleshoot... 

        Are you able to share one full example of {{custom_attribute.${Profiles}}}?

  • In order to dynamically retrieve the 'Colour' value for a specific company e.g., Company A, you can use a similar loop to iterate through custom_attribute.Profiles. Remember within the loop, check if the company matches 'Company A.

    Then reference the associated 'Colour' value. Make sure you are correctly accessing nested attributes like Profiles[n].Colour.  Hope you find this one helpful !