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.
Attachments:
<ul>
{{#issue.attachment}}
<li><a href="{{content}}">{{filename}}</a></li>
{{/issue.attachment}}
</ul>
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:
<ul>
{{#issue.attachment}}{{#if(exists(filename.match("(.*\.docx)$")))}}<li><a href="{{content}}">{{filename}}</a></li>{{/}}{{/}}
</ul>
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:
{{#issue.attachment}}{{#if(exists(filename.match("(.*\.docx)$")))}}{{filename}}{{/}}{{/}}
does not equal Empty. (To ensure that you don't send an email if there are not any docx attachments.)
References:
Hi @Darryl Lee
Is it possible to add Particular file name in attachments to an e-mail with Automation for JIRA
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
match("(MOP.*\.docx)")
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
<ul>
{{#issue.attachment}}{{#if(exists(filename.match("(MOP.*\.docx)")))}}<li><a href="{{content}}">{{filename}}</a></li>{{/}}{{/}}
</ul>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
<ul>
<li><a href="{{issue.attachment.last.content}}">{{issue.attachment.last.filename}}</a></li>
</ul>
But I guess if there might be other documents interspersed amongst the MOP docs. Hrm.
This will work:
{{#issue.attachment}}{{#if(exists(filename.match("(MOP.*\.docx)")))}}{{filename}}{{^last}},{{/}}{{/}}{{/}}
{{#issue.attachment}}{{#if(exists(filename.match("(MOP.*\.docx)")))}}{{content}}{{^last}},{{/}}{{/}}{{/}}
<ul><li><a href="{{allcontents.split(",").last}}">{{allfilenames.split(",").last}}</a></li></ul>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
Email Output:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
Then you will reference those variables in the email, like so:
If you have additional issues, please share a screenshot of your rule.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Darryl Lee for this below screenshot which new action you took for that( Create Variable).
I struck here. Can you please help me out. I am following your steps only.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.