Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How do I add docx attachments to an e-mail with Automation for JIRA

Is it possible to add only docx attachments to an e-mail with Automation for JIRA ?

I am able to attach All the attachments by using below. But only the requirement is needs to add docx attachments. Can anyone help me out how to filter docx files from this.




<li><a href="{{content}}">{{filename}}</a></li>



1 answer

1 accepted

2 votes
Answer accepted

Hi @E Hanumanthu - I think this will do the trick. I had to put it all on one line to avoid Automation adding line breaks in the email:

{{#issue.attachment}}{{#if(exists(filename.match("(.*\.docx)$")))}}<li><a href="{{content}}">{{filename}}</a></li>{{/}}{{/}}

Basically we are trying to match filenames that end with .docx, and if so, then include them.

I would also suggest that if you aren't already you should probably do a check to make sure that this smart value:


does not equal Empty. (To ensure that you don't send an email if there are not any docx attachments.)


Hi @Darryl Lee 

Is it possible to add Particular file name in attachments to an e-mail with Automation for JIRA 

Darryl Lee Community Leader Dec 20, 2022

Hi @Gnana Sekhar Reddy - so if you're asking if you can only include a specific file to the email, yes you would simply change the match() statement above to something like:

... .match("(nameofyourfile\.docx)")

The \ in front of the . is used because . is a "wildcard" character in regular expressions.

Like E Hanumanthu likes this

Hi @Darryl Lee 

But when i am implementing that, getting below error in Audit log(Project Automation), E-mails notification not receiving . Can you help me out from this.

Note: This is file name : MOP-230_Test_1


Error rendering smart-values when executing this rule:
Tokens must be separated by '.': ”))): Hi {{issue.approver.displayname}}, {{issue.reporter.displayname}} has been submitted MOP for your Approval. Please approve it. Thank you. The issue: <a href="{{issue.url}}">{{issue.key}} - {{issue.summary}}</a> Attachments: <ul> {{#issue.attachment}}{{#if(exists(filename.match(“(MOP\.docx)”)))}}<li><a href="{{content}}">{{filename}}</a></li>{{/}}{{/}} </ul
Automation Error.jpg
Darryl Lee Community Leader Dec 21, 2022

Hi @Gnana Sekhar Reddy -- thank you for including the error message. It was very helpful in finding the problem.

The thing that was breaking your rule is that your quotation marks in the match block are curly quotes, not "straight" quotes.

I replaced the quotes with straight quotes, and it got rid of the error.

HOWEVER your rule will not work as intended unless you add a wildcard (.*) to your match, so it should be:


Also, as with my advice to @E Hanumanthu you probably want to do a check to ensure that there is an attachment that matches what you expect before sending the email.

Screen Shot 2022-12-21 at 9.53.55 AM.png

Like E Hanumanthu likes this

Hi @Darryl Lee Thank you so much for your valuable information. 

Hi @Darryl Lee Thank you so much for your valuable information. 

Now I have one more requirement. From this below how can we take only latest version document. Just i want latest one i don't want all the documents with that particular name. Can you please confirm me how can we do that.

Note: Documents should be likes this MOP-230_Test_1, MOP-230_Test_2, MOP-230_Test_3.......etc 

{{#issue.attachment}}{{#if(exists(filename.match("(MOP.*\.docx)")))}}<li><a href="{{content}}">{{filename}}</a></li>{{/}}{{/}}

Darryl Lee Community Leader Dec 22, 2022

Hi @Gnana Sekhar Reddy will any attached documents not be MOP documents?

If they are all MOP docs, then you could just grab the .last attachment:

<li><a href="{{issue.attachment.last.content}}">{{issue.attachment.last.filename}}</a></li>

But I guess if there might be other documents interspersed amongst the MOP docs. Hrm.

This will work:

  • Create variable allfilenames that generates a comma-delimited list of MOP filenames, in order of attachment:
  • Create variable allcontents that generates list of MOP content links, in order of attachment:
  • Update email to use split function to separate out lists of MOP filenames/contents, then use last function to get the last one.
    <ul><li><a href="{{allcontents.split(",").last}}">{{allfilenames.split(",").last}}</a></li></ul>
Like E Hanumanthu likes this

Hi @Darryl Lee 

The above 2  are not working. I am getting all the MOP files/Content links. Can you please looking into it. For your reference i am attaching output also. 

1) {{#issue.attachment}}{{#if(exists(filename.match("(MOP.*\.docx)")))}}{{filename}}{{^last}},{{/}}{{/}}{{/}}

2) {{#issue.attachment}}{{#if(exists(filename.match("(MOP.*\.docx)")))}}{{content}}{{^last}},{{/}}{{/}}{{/}}

Even that's not opening format like this below

Email Out put:

Screenshot Email.jpg


Email Output:

Screenshot 2023-01-12 180342.jpg

Darryl Lee Community Leader Jan 13, 2023

Hi. I think you may not have fully understood my instructions.

It looks like what you included in the email are supposed to be intermediary variables that are later used within the email.

So you need to use the Create variable action to create the variables I mentioned, like so:

Screen Shot 2023-01-13 at 1.42.44 AM.png

Then you will reference those variables in the email, like so:

Screen Shot 2023-01-13 at 1.43.07 AM.png

If you have additional issues, please share a screenshot of your rule.

Hi @Darryl Lee Please find attached Screenshot of my Automation rule.


Screenshot Automation rule.jpg 

Hi @Darryl Lee for this below screenshot which new action you took for that( Create Variable).

Screenshot 2023-01-13 172426.jpg

I struck here. Can you please help me out. I am following your steps only.

Screenshot 2023-01-13 172632.jpg

Darryl Lee Community Leader Jan 13, 2023

The manual trigger I am using is just for testing.

What you need to do is edit your existing rule and insert the 2 "Create variable" actions after your trigger, and then update the Attachments section of your email to use the code I gave you (that includes the "split" commands).

Hi @Darryl Lee is it possible to attach(Implement smart Values) based on Current Document Version of an Jira issue. For your reference find attached screenshot.

If possible means that could be find so we can easily attach latest version document.

Screenshot 2023-01-16 210110.jpg

Darryl Lee Community Leader Jan 16, 2023

I don't think there's a way to use a field value as part of a match function, so no, I don't think that will work.

Again, in my testing, I used the Create variable action to create two variables, and then I referenced those variables in the email, and this seemed to consistently get the most recent attachment.

The screenshot you shared did not contain those actions, nor do I see the check I suggested to ensure that there is in fact a MOP.*\.docx file attached.

Again, I would go back to my previous screenshots and steps that I shared, and make sure you include all the steps. You can't skip any and expect this to work.

Hi @Darryl Lee I am unable to create the Create Variable in Jira Automation. We are using DC Flat form. Is there any option to create that in DC Level. Can you please confirm me.Screenshot 2023-01-17 145834.jpg 

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events