Question

Photo of Knolly Shadrache

0

Entity Command Where clause fails with Boolean attribute?

Hi I'm trying to retrieve entities that have a Boolean attribute set to 'true', but I'm getting a casting error on every variation I try.

{% location where:'LargeFormatRoom==true' %}{% endlocation %}

and

{% location where:'LargeFormatRoom==1' %}{% endlocation %}

and

{% location where:'LargeFormatRoom=="Yes"' %}{% endlocation %}

Produce:

Liquid error: Invalid cast from 'System.String' to 'System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'.

Can anyone shed light on this please?

  • Photo of Mike Mundy

    0

    I see that too. I'm not sure if it's a bug or not. 

    Here's a workaround:

    {% location where:'LocationTypeValueId == 183' %}

        {% for loc in locationItems %}

            {% assign largeFormatRoom = loc | Attribute:'LargeFormatRoom' %}

            {% if largeFormatRoom == 'Yes' %}

                {{ loc.Id }}

            {% endif %}

        {% endfor %}

    {% endlocation %}

    • Knolly Shadrache

      Thanks for this, that should work.


      I do think that if the actual and expected behaviours differ under one particular setup in a way that isn't in the manual it might be an edge case bug?

  • Photo of Mike Mundy

    0

    Something like this should work:

    {% location where:'LargeFormatRoom == Yes' %}

        {% for loc in locationItems %}

            {{ loc.Id }}

        {% endfor %}

    {% endlocation %}

    • Knolly Shadrache

      Yes, I agree, but unfortunately the outcome is exactly the same:


      Liquid error: Invalid cast from 'System.String' to 'System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'.


      I'm stumped!

  • Photo of Mike Mundy

    0

    Interesting - it is working in Lava Tester in my instance.

    Screenshot_2022-12-12_at_08.51.42.png

    • Knolly Shadrache

      I thought I had found the answer, but it seems not so I deleted it just now.


      The problem seems to be related to the attribute qualifier which I have in place.


      If I remove that qualifier I get the same outcome as you are seeing. But If I put the qualifier back again, I get the same error.


      Is this a bug or am I doing something wrong?

  • Photo of Mike Mundy

    0

    Instead of "EntityTypeValueId", try "LocationTypeValueId"