Recent searches


No recent searches

Trigger - Count Attachments

Answered


Posted Jul 30, 2021

Hello, I'm using the following code in a trigger.

{% for comment in ticket.comments limit:1 offset:0 %}
{{comment.value_rich}}
{% for attachment in comment.attachments %}
{{attachment.filename}} - {{attachment.url}}
{% endfor %}
{% endfor %}

Can I check in the loop whether the comment has an attachment in order to show additional text? Something like that 

{% for comment in ticket.comments limit:1 offset:0 %}
{{comment.value_rich}}
{% IF COMMENT HAS ATTACHMENTS %}
Notice: You have to log in to be able to download the attachment. If you don't have an account yet, click Send Password. 
{% for attachment in comment.attachments %}
{{attachment.filename}} - {{attachment.url}}
{% endfor %}
{% ENDIF %}
{% endfor %}

What would be the right condition?


0

2

2 comments

image avatar

ZZ Graeme Carmichael

Community Moderator

Linus

Try this:

{% for comment in ticket.comments limit:1 offset:0 %}
{{comment.value_rich}}
{% unless comment.attachments == empty %}
You need to log in to download attachments.
{% for attachment in comment.attachments %}
{{attachment.filename}} - {{attachment.url}}
{% endfor %}
{% endunless %}
{% endfor %}

2


Hi Graeme, that is the solution. Great!

 

0


Post is closed for comments.

Didn't find what you're looking for?

New post