Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Send an email with a list of work items that contain attachments with long filename

Pavol Sočuvka
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 29, 2025

Hi all, 

I would like to get a list of work items that contain an attachment that has a filename longer than 50 chars. Then, I'd like to send this list as an email. 

What I tried is:

Smart value comparison:

  • Run a scheduled rule with a JQL search (attachments is not empty)
  • Compare smart value {{attachment.filename.length}} greater than 50
  • Then send an email.

  • Caveat: Sends multiple emails because of the 'Scheduled' trigger. Works OK with logging to audit log 

Conditional expression

  • Run a scheduled rule (or manual for testing)
  • Lookup work items (attachments is not empty)
  • Send an email with a conditional smart value expression 

  • Caveat: Doesn't work. I have tried
({{#if(issue.attachment.filename.length.gt(50))}} {{lookupIssues}} {{/}} 

or

{{#lookupIssues}}
* {{#if(attachment.filename.length.gt(50))}} {{key}} {{/}}
{{/}}

 I can't seem to be able to get the syntax right.

What does everyone think? I'm tempted to tag the automation goat @Bill Sheboy , I think you might like this.

1 answer

1 vote
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 29, 2025

Hi @Pavol Sočuvka -- Welcome to the Atlassian Community!

One challenging part of this scenario is the nesting lists (i.e., work items and their attachments) and distinguishing between what I call "section breaks" versus the built-in "list filtering":

  • section breaks -- Identify when a condition applies, but do not filter to the child-list data
  • list filtering -- This is the built-in feature using conditional expressions to filter a list

When one filters too early, no other data is available, such as the work item key.

 

You want "section breaks" to identify the work items meeting the condition, and perhaps to then list the specific keys and attachment filenames.  For example, with extra line breaks to help explain it:

items with longer than 50 char attachments: 

{{#lookupIssues}}
{{#if(attachment.filename.length().gt(50).join(",").split(",").match("(true)").size.gt(0))}}
{{key}}:
{{#attachment}}
{{#if(filename.length().gt(50))}}
{{filename}},
{{/}}
{{/}}
{{/}}
{{/}}

How that works is:

  • with long-format iteration over the work items in the lookup results
  • we test if any of the attachments in the nested list have long filenames
    • using inline iteration over the attachment filenames
    • we get the length of each one
    • testing that length is greater than 50 characters, producing a list of Boolean values
    • we force conversion to text with a join()
    • then split() back into a list of text values
    • we filter the text list using a match() to find positive results
    • we count the remainder with size
    • finally testing with gt(0)
  • now, we know there is at least one attachment in the work item with long filename
  • and we can return the key and use built-in list filtering to return each filename
  • if you only want the key, just drop that last iterator

 

I helped someone last year with a similar scenario to create a worklog report by user, spanning multiple work items to sum logs, as a table.  As with your scenario, this only works because the test value 50 can be hardcoded.  If the 50 was dynamic, a more complicated approach is needed, as described in this article.

 

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events