How can I reveal CCs in a notification email using Liquid markup?

Have more questions? Submit a request

35 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
  • Raman Kalia
    Comment actions Permalink

    Resurrecting the thread. I'm trying to add a tag in the ticket if CC field is not empty. Following code is being called but not working.

    {% if ticket.cc_names != empty %}

    {“ticket”: {“additional_tags”: [“cc_true”]}}

    {% else %}

    {% endif %}

    HTTP Target - https://mysubdomain.zendesk.com/api/v2/tickets/update_many.json?ids={{ticket.id}}

    Have also tried in place of {% if ticket.cc_names != empty %} with no success.

    {% if ccedusers != empty %}
    or
    {% if ccedusers contains '@' %}

    Any idea...

    0
  • Santiago Saez
    Comment actions Permalink

    Hi,

    Is there any way to filter by organization? 

    I only want one organization to recieve the CCs to try for a few weeks and have some feedback.

    I've tried adding {% if user.organization.name contains 'XXXX' %}

    but it's not working

     

    thanks!!

    0
  • Eli Webster
    Comment actions Permalink

    Why not change the first "unless" to an "if", like this (taken from my post 3 years ago):

     

     {% if cc.email contains 'clientdomain.com' %}
      {% unless forloop.last %}
       {{ cc.name | prepend: '"' | append: '" '}} {{ cc.email | prepend:'<' | append: '>, ' }}
      {% else %}
       {{ cc.name | prepend: '"' | append: '" '}} {{ cc.email | prepend:'<' | append: '>' }}
      {% endunless %}
     {% endif %}
    0

Please sign in to leave a comment.

Powered by Zendesk