Using Liquid markup to reveal CCs in a notification email

Have more questions? Submit a request

32 Comments

  • Eli Webster
    Comment actions Permalink

    If you want them to appear on multiple lines, and you wanted your custom text to only show if there are actual CC's, and you wanted even your own agents to show up as being CC'd, I would do this:

    The first line is just standard "CC E-mail" text. You can remove it if you don't want it.

    You are registered as a CC on this help desk request (#{{ticket.id}}). Reply to this email to add a comment to the request.

    {% if ticket.cc_names != empty %}
     {% capture ccedusers %}
     {% for cc in ticket.ccs %}
       {{ cc.name | prepend: '"' | append: '" '}} {{ cc.email | prepend:'<' | append: '>' }}
     {% endfor %}
      {% endcapture %}
    {% if ccedusers contains '@' %}
     Here is where you custom text would go and would only show if there is a CC.

     {{ ccedusers | replace:'&quot','"' | replace:'&lt','<' | replace:'&gt','>' | replace:';','' }}
    {% endif %}
    {% endif %}
    {{ticket.comments_formatted}}

    Keep in mind the lines that append and prepend are used for housekeeping. It basically changes something like:

    John Smith jsmith@domain.com

    to

    "John Smith" <jsmith@domain.com>

    which is more in line with standards. And the lines that replace is because I found it sometimes to show the word "&quot" so it changes it to just an actual " sign.

    0
  • Pepijn van de Vondervoort
    Comment actions Permalink

    Thanks Eli.

    Question: when there are no CC'd persons in the ticket, your code is automatically hidden. Thats great!

    But that does leave some unnecessary white space (enters) behind which isn't very neat.

    Is it somehow possible to remove this side-effect?

    0

Please sign in to leave a comment.

Powered by Zendesk