Automation rule when a comment added with attachment(s)

Puján Z
Contributor
February 2, 2023

Hello,

I would like to create an automation rule, that would run when a comment is added with attachment, and create an issue with the comment-attachment added to the issue.

Is there a way to do this with Jira Automation? I couldn't find a condition that checks whether the added comment has an attachment or not. And for creating an issue, I don't know how to add ONLY the attachment that was added in the comment to the created issue.

Any help is appreciated :)

Cheers, pj

3 answers

1 vote
FF
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!
December 19, 2024

After some trial and error, I've found that the following automation structure seems to achieve the goal of detecting if an attachment is contained within a comment. The only caveat is the "regular expression" portion of the condition must include the attached filetype in the regex query, otherwise the automation fails to trigger.

Screenshot 2024-12-19 at 9.46.56 AM.png

Trigger:

  • issue commented
    • Comment is the main action

Condition:

  • {{smart values}} condition
    • First value: {{triggerIssue.comment.last.body}}
    • Condition: Contains Regular Expression
    • Regular Expression: \.(fileType1|fileType2|fileType3|etc)

 

1 vote
Uladzislau Samuseu
Contributor
November 1, 2024

For myself, I found a solution:

If some file is not displayed, then use {{issue.comments.body}} after you have loaded this file in the comment to see what distinctive words or characters the file contains

Karolina Dylewicz November 13, 2024

looks like this is what I'm looking for :D

 

Like Uladzislau Samuseu likes this
Karolina Dylewicz November 17, 2024

@Uladzislau Samuseu have you figured out the smart value for the attachment in the last comment?

What I've noticed is that when I refer to the {{issue.comments.last.body}} then I get the body of the actual last comment added, but it's only the name of the attachment in text form. 

By contrast, {{issue.attachment.last.content}} doesn't give me the last added attachment, but the last attachment of all attachments from the issue and they're sorted by NAME, not by DATE. So if my attachment starting with Z was added 3 comments ago and now I'm adding an attachment with B, this smart value still gives me attachment with Z. 

Maybe you know how to handle this? 

Uladzislau Samuseu
Contributor
November 17, 2024

@Karolina Dylewicz, If I understand the logic of your rule correctly, then most likely these ideas will help you: 

  • when you need to handle the last added attachment to "Attachment" block you have to use this logic: https://prnt.sc/1zTynPMRngZF (in this case the attachment is already last, cuz automation run when attachment added). Now you can access to the object by {{issue.attachment.content}}.
  • when you need to handle the last added attachment (screens or docs) to "Activity" (comments) block you have to use this logic: https://prnt.sc/BKzb6ssxg1-B  (in this case the attachment is the last too, cuz automation run when comment added). And now you can access to the object by {{issue.comment.body}}.
Karolina Dylewicz November 18, 2024

thanks!

I'll try this, just bear in mind that we're talking about DC, not Cloud. Though this article was for Cloud. 

The first logic in my previous tests didn't react to comments added from the portal. I'll check again with your exact config. 

:) 

Like Uladzislau Samuseu likes this
Karolina Dylewicz November 18, 2024

hi @Uladzislau Samuseu , so I've been checking this and this {{issue.attachment.content}} prints all attachments present on the trigger issue, not only the one added as last :(

and the second option does't work for comments added via portal. 

 

have you got any other ideas? especially some smart values for issue.comments.last.body/attachment.filename.   etc.

Uladzislau Samuseu
Contributor
November 18, 2024

@Karolina Dylewicz

Thease work correctly for me in Cloud version (I haven't encountered the desktop version)

  • {{issue.attachment.first.filename}} and {{issue.attachment.last.filename}} 
  • {{issue.comment.first.body}} and {{issue.comment.last.body}}

In case with comments try to use "comment" instead of "comments".

0 votes
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 3, 2023

Hi @Puján Z 

First of all: What is the use case behind this requirement? Why would you like to copy an attachment (that is obviously meant to be part of an issue) to another issue?

As far as my knowledge reaches there is no condition to grab an attachment of a comment and furthermore hand it over to another issue.

I can´t tell 100% sure but I can imagine that Rest API calls could maybe handle this problem. So you could try to add a "send webrequest" action in your rule to grab the attachment.

Furthermore: What do you mean with "ONLY" adding the attachment? When creating an issue at least the summary field is required. 

 

Best
Stefan

Puján Z
Contributor
February 3, 2023

Hi Stefan,

We use Jira as a comprehensive ERP system. Probably the first one in the world to do so, and the landscape and interplay of apps in pretty complex. So a lot of things we do is not common practice ;)

If you have to know the requirement in order to come up with a workaround: we are connecting Jira to an AI-System to read and categorize attachments automatically. That is why every attachment is handed over to an "attachment handling" issue, in which they are analyzed, categorized, and the extracted attributes are verified and delivered to the target issue.

For this, when an email with an attachment is sent to and captured by Jira, this attachment (and only this one, and not the already existing attachments) needs to be sent to our AI-system vai API or email. I was trying to do this with Automation, but it seems it is not possible. And considering Atlassian's response time in developing new features, we now need to look for another solution to get the attachment it seems.

Cheers

Like brady.leach likes this
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 3, 2023

As i mentioned in my post before there are other ways in between „automation for jira“ amd „waiting for new features“.

As you explained what you are trying to do i assume you are not a tech newby so I would suggest to check out the API documentation. 

Furthermore:

Do you have scriptrunner plugin installed?

Best
Stefan

Suggest an answer

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

Atlassian Community Events