Need to get the attachments in the email for the assignee

Deleted user October 20, 2023

I had written the below code to get attachment in the email and it is not working please let me know where is the mistake.

Hi {{issue.assignee.displayName}},

The following issue has attachment linkage:
{{issue.key}} - {{issue.summary}}

{{#issue.attachments}}
-[{{filename}}]({{URL}})
{{/issue.attachments}}

Learn more about this issue: {{issue.url}}

Regards,

Jira Automation

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.
October 20, 2023

Hi @[deleted] 

What is not working as you expect?

If you are not getting a URL to the attachment file, try using the {{content}} smart value instead.  And consider that only recipients with a Jira user will be able to access that URL.

If you are expecting an image of the attachment file to appear in the email, that is not possible at this time with outgoing emails.

And for your iterator, I suggest simplifying to avoid having errors in your message.  For example:

{{#issue.attachments}}
-[{{filename}}]({{content}})
{{/}}

Kind regards,
Bill

Deleted user October 23, 2023

Hi Bill,

 

I need the attachments in the email for the assignee of the defects. 

I had tried with the above one but unable to get it Can you please check and let us know if there is code to get the attachments in the email.

 

Thanks

Anjireddy 

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.
October 23, 2023

I do not believe that is possible. The rule actions for emails do not send the attachment, and while there is a REST API function to get an attachment, but that cannot be used to send it in the rule's email action.

Deleted user October 26, 2023

Hi Bill,

 

Can you provide the code which we can get the URL of the attachment in the email.

URL is also fine for us please let us know.

 

Thanks

Anjireddy

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.
October 26, 2023

Please see my first post in this thread, as it shows the {{content}} attribute of attachments, which provides a URL a licensed Jira user can access.

Deleted user October 27, 2023

@Hi @Bill Sheboy 

 

I had tried with the above code which you had provided but not received any content or the URL please let me know how to write this.

 

Thanks

Anjireddy

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.
October 27, 2023

Please post an image of your complete rule (in one image), images of each action / condition / branch, and an image of the audit log details showing the rule execution.  Those may provide context to explain what is happening.

Again regarding my first post: I tried that and it provided a URL which may be used to trigger a download, when used in an email.

Deleted user October 27, 2023

Hi Bill,

 

Please find the attached logs and content.Script logs.JPGScript content.JPG

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.
October 27, 2023

The audit log shows the cause of the symptom: 

Your trigger is using JQL, and you have selected the option to not include issues which have not changed since the last run execution.  And so there are no issues to process.

I recommend considering what you want to do: leave the rule as-is, or remove that option from the trigger.

And...The conditions in your rule could be removed and added to the trigger JQL with this:

AND assignee IS NOT EMPTY AND attachments IS NOT EMPTY

Deleted user November 1, 2023

Hi @Bill Sheboy

 

Thanks for the update it worked and we got the links in the email but we are unable to open that links getting the below error.

 

error.JPG

Thanks

Anjireddy

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.
November 1, 2023

Only people with Jira access (and access to the specific issues) will be able to view those attachments using the link.

Deleted user November 1, 2023

Hi Bill,

 

I had the access to the Jira and for the issue as well.

 

Thanks

Anjireddy

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.
November 1, 2023

I just re-tested this for an issue that I have access to, and was correctly prompted to download the attachment.

If you go to the specific Jira issue for that attachment:

  • can you view the issue
  • can you download the attachment for the issue

 

If you can, I suggest working with your Jira site admin to submit a ticket to Atlassian Support here: https://support.atlassian.com/contact/#/  They may see something in their internal logging to explain this permissions issue.  

When you hear back from them, please post what you learn to benefit the community.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events