Question

Photo of James Temens

0

Label Merge Field - Phone Number

We are trying to get the phone numbers of the parents to show up on the check in labels and I wrote the following lava code which works from web page when I add the markup tags and sign in as a child of a parent.  However, when I place this into the label merge field and assign it to the label nothing happens.  Any ideas?

{% assign parents = Person | Parents %}

    {% for parent in parents %}

        {% if parent != empty %}

            {% if parent.PhoneNumbers != empty %}

                {% assign PhoneMobile = parent | PhoneNumber:'Mobile' | AsString %}

                {% assign PhoneHome = parent | PhoneNumber:'Home' | AsString %}

                {% if PhoneMobile != null %}

                    C: {{ PhoneMobile }}

                {% endif %}

                {% if PhoneMobile == null and PhoneHome != null %}

                    H: {{ PhoneHome }}

                {% endif %}

            {% endif %}

        {% endif %}

    {% endfor %}

  • Photo of Lee Peterson

    0

    Well, the 9 is definitely being replaced by nothing. I'd suggest printing at least one more field to make sure you know who it is you're checking in.

    The "Parents" Lava filter was broken in v7, but fixed in 7.4 (https://github.com/SparkDevNetwork/Rock/issues/2830). Do other filters work? That might be a clue. I wonder if there's any chance some code didn't install or get updated correctly.

  • Photo of Lee Peterson

    0

    It works for me. Is it possible the field on your label isn't quite right?


    Edit:

    Because of the formatting, it was sending a lot of spaces and linefeeds (it still worked for me the way it was, though). This gets rid of all the white space, but leaves stray line feeds, which could be eliminated by putting everything on one line:

    {%- assign parents = Person | Parents -%}

        {%- for parent in parents -%}

            {%- if parent != empty -%}

                {%- if parent.PhoneNumbers != empty -%}

                    {%- assign PhoneMobile = parent | PhoneNumber:'Mobile' | AsString -%}

                    {%- assign PhoneHome = parent | PhoneNumber:'Home' | AsString -%}

                    {%-if PhoneMobile != null -%}C: {{ PhoneMobile }}{%- endif -%}

                    {%- if PhoneMobile == null and PhoneHome != null -%}H: {{ PhoneHome }}{%- endif -%}

                {%- endif -%}

            {%- endif -%}

        {%- endfor -%}

    This code prints the phone numbers all on one line. You'd have to add '\&' line feeds to split them over multiple lines.

  • Photo of James Temens

    0

    So I mapped the merge field with the code above to the 'Notes' field on the label which I know worked when it was mapped to the notes and I still get a blank.  Very weird...

    • Lee Peterson

      I mapped it to the "9" field on the stock child icon label, which prints two lines and it works. I wonder if it's because that field prints a field block and your notes field (likely) prints one line? The extra spaces might affect a non-field block line.

    • Lee Peterson

      Yes, I think that's it. I mapped your original code to both the nickname and "9" fields, and it only prints on the "9" field. The modified code I posted works on both fields. The reason it doesn't appear to print is that it's printing all the spaces, and your phone numbers are off the right side of the label.

  • Photo of James Temens

    0

    I don't have a nickname field listed but, I did map the code to field number 9 and nothing showed.  However, if I map the first and last name to the number 9 field it does show.



  • Photo of Lee Peterson

    0

    I'm not sure what to suggest. On the left is a hex dump of your code as sent to the printer, with all the spaces and line feeds surrounding the phone numbers. The right top label is the stock child icon label, with the merge field (with your original code in it) assigned to both the nickname (I think that's the "5" field), and the "9" field (originally assigned to locations and times). The lower label is with the code I modified printing to the same two fields.

    I assume that you're checking someone in who has parents with phone numbers (dumb question, I'm sure).
    You have to be a little careful when changing a merge field in pre-8.4 versions -- you have to clear the Rock cache to see immediate effects. You should also make sure that label caching is turned off on whatever device you're using for check-in.




    IMG_3181.jpg

  • Photo of James Temens

    0

    I tried just printing the parents names using the Label Merge Field below and it prints on the web page but, prints nothing on the label no matter what field I map it under:

    Capture3.PNG

  • Photo of James Temens

    0

    How do you clear the Rock cache?  I am using 7.4....

  • Photo of Lee Peterson

    0

    Hover at the bottom of the screen and bring up the admin toolbar. Click on the "i" in the circle and it'll display a clear cache button.

    If you put only some text in the merge field in place of the Lava, does it print?

  • Photo of James Temens

    0

    Here is my complete picture map of my setup.  I put the printer in dump mode to show what was coming out:

    IMG_20181105_205110.jpg

    IMG_20181105_205214.jpg

    IMG_20181105_205144.jpg

  • Photo of James Temens

    0

    If I use any Lava code it works with the exception of the "Parents" lava filter.  I thought we were on 7.4 but, I am going to check again - I believe it may be the issue you linked in your post.  I will reply back when I find out...