Forums

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

Update a Parent Case with an attachment made in the last comment of a subtask

Rus Yates-Aylott
Contributor
January 31, 2025

Hi.
I have created a rule that captures the last comment made in a subtask when the subtask transitions to Further Information Required. The subtask comment is always updated when this transition occurs, and the automation adds that comment to the Parent case.

What I am trying to ensure is that, should that subtask's comment also contain an attachment, that too is copied across to the Parent case.

What I do NOT want is any attachment from the subtask that is NOT associated with the transitional comment mentioned above. In other words, simply adding the Last attachment may not work if the last attachment was made before the transition.

Any ideas anyone?
 

2 answers

0 votes
Beth Sanders
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!
June 5, 2025

Hey I am in a similar boat, can you share the automation you created to write the parent comment? I am trying to copy a comment made on a child issue (Spike) to the parent issue (Epic) - ideally with the author and date in plain text format.

Rus Yates-Aylott
Contributor
June 6, 2025

Hey Beth.
Thanks for reaching out. I will do my best. Bear in mind this solution does NOT copy over the attachment but adds a link to the attachment so it can be accessed from the parent case. It's a little complex but I will do my best to explain the steps:

Screenshot 2025-06-06 080859.png
The third element above (Latest Attachment) refers to a custom field in the subtask which will be used later. Here, we are simply ensuring it is cleared (empty)
Use {{issue.comments.last.body}} for smartLastComment
The branch js an if/else block...
Screenshot 2025-06-06 081242.png
The 'IF' condition checks that the last comment was an Internal one and the 'ELSE' whether it is public. The 'smartCommentVisibility' variable captures this so it can be identified later You may or may not require this.
Now we can create a couple of smart values used to check the timing of the last attachment added:
Screenshot 2025-06-06 081614.png
smartNowMillis looks like this: {{#now}}toMillis{{/}}
smartMinusMillis looks like this: {{#=}}{{smartNowMillis}}-30000{{/}}
Note the leading # and trailing / signify the equation is a math function.
Now we can branch and review the last attachment:
Screenshot 2025-06-06 082053.png
The branch uses Advanced branching based on a smart value. We use {{attachment.created}} and give it a variable name of 'smartAttachment'
Then we create two new Smart Values.
'smartMatch' is initially set to 'false'
'smartAdate' converts the 'smartAttachment' value to millis using: {{#smartAttachment}} format="toMillis"{{/}}
(note the double quotation marks)
Now we can begin processing our findings:
Screenshot 2025-06-06 082711.png
The Compare two values condition compares whether {{smartAdate}} is greater than {{smartMinusMillis}}
What we are doing here is checking if the attachment we are looking at whether the date of the last attachment was within the last 30 seconds. (If true we can assume the last attachment was added as part of the last comment.)
So we can then set 'smartMatch' to true and create 'smartAttachmentIDs' to capture {{issue.attachment.id}}
'smartAttachmentIDmax' uses {{issue.attachment.id.max}} to ensure we have the ID of the very latest attachment added.
There are just two more steps in this branch:
Screenshot 2025-06-06 083639.png

smartAttachmentURL uses the following value to grab the url of the last attachment:
https://<yourdomain>.atlassian.net/rest/api/2/attachment/content/{{smartAttachmentIDmax}}
Then we edit the subtask's fields and set a custom field as follows:
Field name: Latest Attachment
Field Value: {{smartAttachmentURL}}
The purpose of this field will become clearer in the next steps.
Back on the main branch we perform a couple of re-fetches to ensure our ticket is ready for the next steps.
We branch again. This time, based on the Parent.
Screenshot 2025-06-06 084242.png
First on this Parent branch, we re-fetch the data for the Parent ticket
Then we check that the trigger issue (the subtask we have just been working on) has a value set in the Latest Attachment field, as follows:
{{triggerIssue.Latest Attachment}} does not equal Empty
Then we create another smart value:
smartLink with the value: *Comment Attachment:* {{triggerIssue.Latest Attachment}}
And now we branch for the last time; Again based on the Parent:
Screenshot 2025-06-06 084925.png
All we are doing here, is adding a Private Comment back to the Parent ticket with the following contnbt:

[~accountId:{{assignee}}]
Platform Subtask: {{triggerIssue.key}}

*Last Subtask Comment:* ({{smartCommentVisibility}})

{{smartLastComment}}

{{smartLink}}

The 1st line ensures the assignee is tagged in the comment
There's a link to the subtask
Then (in bold) we start to display the last subtask comment, beginning with its visibility setting, followed by the comment itself, and finally, the url of the last attachment.

I hope you are able to follow this and it makes sense to you. You will have noticed I use a lot of Log Action to Audit Log elements. These are very useful in debugging.
Good Luck

Like Beth Sanders likes this
Rus Yates-Aylott
Contributor
June 6, 2025

Let me know if this has been useful

Like Beth Sanders likes this
Beth Sanders
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!
June 6, 2025

Wow this is so thorough and extremely helpful, my case is a bit simpler as I don’t need an attachment, but I do need the same comment values you reference here. This is exactly what I needed, thank you so much I really appreciate how much effort you put into this!

0 votes
Rus Yates-Aylott
Contributor
January 31, 2025

Thinking on the fly here.

What if...
I could get the timestamp of the last comment (the one created as part of the transition) and the timestamp of the last attachment and then...

If they match (within a few seconds) the chance is, they're connected ad i can then proceed to add the last attachment to the Parent case?

If anyone has any idea on how the above could be structured, I would be really grateful.

 

Rus Yates-Aylott
Contributor
January 31, 2025

I have made some progress in that I can pull the DateTime dtails for all attachments in the subtask and accepting a 10 second variance, identify an attachment that has very recently been added.
The question now is how to actually copy that latest attachment to the Parent without copying all attachments. Now I'm stuck

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