Question

Photo of Knolly Shadrache

0

How to get Membership in a specific Group for a person using in the Id?

Hi,

I'm probably making a simple error, but I cannot seem to get a basic lava query to work in lava tester or lava template:

Hard coding the Id in a group member query works ok:

{% assign gm = person | Group:"3933" | First %}


But I need to use row.GroupId as I'm building a dynamic report with a lava template. It fails to return anything if I substitute the GroupId with a lava value:

{% assign gid = row.GroupId | Property:'Id' %}

{% assign gm = person | Group:'{{gid}}' | First %} ---> nothing returned

{% assign gm = person | Group:'"{gid}}"' | First %} ---> nothing returned

Does anyone know the correct this at all? the docs don't seem to cover it and I've been at it for hours.

Hope someone can rescue me please....


Thanks


  • Photo of Daniel Hazelbaker

    0

    You would need to use a syntax like:

    {% assign gm = person | Group:row.GroupId %}

    You may get an error about not being able to convert an int32 to a string. If you do you are hitting a bug in how that filter works. To get around it you can do something like:

    {% capture gid %}{{ row.GroupId }}{% endcapture %}
    {% assign gm = person | Group:gid %}

    That should force convert the GroupId integer value into a string.

    This all assumes that "row.GroupId" contains the Id number of the group. :)


    Usually, when working with Lava Filters, you can pass one of 3 things:

    1) An Integer, example: {{ CurrentPerson | MyFilter:123 }}
    2) A string, example: {{ CurrentPerson | MyFilter:123 }}
    3) A variable, example: {{ CurrentPerson | MyFilter:SomeVariable }}

    Where "SomeVariable" is something you assigned previously with the {% assign %} or {% capture %} commands, OR is a variable that is pre-defined for you.

    Hope this helps!

    • Knolly Shadrache

      Thanks!! I had encountered the int32 string conversion error and wasn't aware of the bug in the filter, glad to know now.


      I just tried the following in Lava Tester based on your pointer and had success!!:


      {% assign gid = Group.Id | ToString %}
      {% assign gm = Person | Group:gid %}
      {{ gm }}


      Thank you ever so muchly!!