Heads up! On March 5, starting at 4:30 PM Central Time, our community will be undergoing scheduled maintenance for a few hours. During this time, you will find the site temporarily inaccessible. Thanks for your patience. Read more.

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

Copy documents to subtasks and all linked issues after parent creation without duplication

VVC
Contributor
March 4, 2025

When a document is attached on a parent ticket randomly and after its creation, it needs to be copied to all existing subtasks and linked issues.

My automation rule works mostly but the problem is that whenever it runs, all existing attachments along with new attachment are copied from main ticket to subtasks and linked issues each time, which is not desired.

Any suggestions on how to get this problem fixed?

Automation Rule Copy Attachments.png

 

 

1 answer

0 votes
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.
March 4, 2025

Hi @VVC 

The current Edit Issue action for the Attachments field copies all of them, and there is no way to limit that.  I recall some suggestions to make that configurable for Jira Cloud but do not know if there is also a suggestion for Jira Data Center automation.

Here are workarounds I have read about, although I have not tried these:

  • Use the REST API to get the attachment as data and then use the REST API to add it to the other issues.  That seems like it would be quite slow for your scenario.
  • Rather than adding the new attachment to each issue, add a link to the single copy stored in the trigger issue
  • And the brute force approach...
    • For each issue being updated, get the list of all current attachments
    • Use the built-in Edit Issue action to copy all of the attachments
    • Identify the ones not needed (based on the original list and the added attachment), and then remove them using the Delete Attachments action.  To me, this approach seems quite risky.

Kind regards,
Bill

VVC
Contributor
March 5, 2025

Hello @Bill Sheboy

Are there any articles or posts in regards to your proposed workarounds as to get this started and for my reference? Thank You!

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.
March 5, 2025

For the REST API approaches, here is a how-to article for calling a REST API endpoint from a rule: https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828

Here is the endpoint to get an attachment by its ID: https://docs.atlassian.com/software/jira/docs/api/REST/9.13.0/#api/2/attachment-getAttachment

Here is the endpoint to add an attachment: https://docs.atlassian.com/software/jira/docs/api/REST/9.13.0/#api/2/issue/{issueIdOrKey}/attachments-addAttachment

 

The second approach of adding a link would just use the attachment's URL smart value, although I do not know if that exists for Jira Data Center automation rules.  I could be manually created using your Jira URL and the attachment's ID.

 

The third approach is just a bunch of list processing and using the built-in actions.  As I noted, it seems the most risky approach due to the chance of errors, so I would not initially try it. 

Like VVC likes this
VVC
Contributor
March 5, 2025

Great! Thanks Bill. I will have to play a lot with the REST API approach but have to defer to later due to other competing priority Jira projects. Thanks again for your support.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events