Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

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

Get last added attachment to issue using smart values

Sebastian Krzewiński
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 13, 2020

Hi

 

Is it possible to get name or id of last added attachment to issue using smart values?

I tried issue.attachment.id.last but it get last item from attachments list.

 

Regards,

Sebastian

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Paul McCulloch
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!
January 16, 2023

I've got a similar requirement. My solution was to create an automation with a Field value changed trigger monitoring 'Value added' for 'Attachment'.  I use the smart value {{addedfieldChange.valueIds}} to get the id of the added attachment.

This was sufficient for my use case (notifying an external app when a file was attached). I suppose you could trigger an update to a custom Jira field to track the last added attachment?

0 votes
Michael March
Contributor
September 13, 2020

I'm not sure if this helps you exactly but if you use the smart value: {{attachment.created}}, it will give you a comma separated list of the creation date of all the attachments on an issue.

Sebastian Krzewiński
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 14, 2020

Hi @Michael March 

Thanks for tip but this is not what I need.

I need to get last added attachment. Dates are ok but I can't work in automation and search attachments based on creation date.

 

Regards,

Seba

Stuart__ February 12, 2021

Hello

It is possible to use the smart value {{issue.attachment.last.id}}.

However, I find it very unreliable and inconsistent and it often does NOT report the last Id.

You should experiment with that - how is it different from what you tried at first?

Sebastian Krzewiński
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 24, 2021

Hi @Stuart__ 

 

*.first or *.last return first/last item from attachment list. In many cases last attachment on list isn't last added attachment.

 

I fixed this by using script runner in automation for jira. This gave me attachments list which I was able to use in automation.

 

Regards,

Seba

Like # people like this
Fabrizio Galletti _Getconnected_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 26, 2021

@Sebastian Krzewiński can you share this?

Sebastian Krzewiński
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 26, 2021

@Fabrizio Galletti _Getconnected_ 

since February my rule change a lot and I switch making a attachment list from scriptrunner to automation's smart values. 

It looks like below:

"attachment":[{{#issue.attachment}}{"id":"{{id}}","author":{"name":"{{author.name}}","key":"{{author.key}}","emailAddress":"{{author.emailAddress}}"},"filename":"{{filename}}","created":"{{created}}"}{{^last}},{{/}}{{/}}]}},
Like # people like this
Zuheb Khan May 17, 2022
"attachment":[{{#issue.attachment}}{"id":"{{id}}","author":{"name":"{{author.name}}","key":"{{author.key}}","emailAddress":"{{author.emailAddress}}"},"filename":"{{filename}}","created":"{{created}}"}{{^last}},{{/}}{{/}}]}},

 This is still giving all the attachment in the webhook logs, I am also struggling to find an answer to just include the last attachment in last transition screen.

Did this work for you with only last attachment ? @Sebastian Krzewiński 

Like Antoine _Klee Group_ likes this
Antoine _Klee Group_
Contributor
June 19, 2023

Hey all.

I am running into the exact same issue at the moment.

I want to retrieve the last added attachment author's and id.

Just as you, I am so disapointed that the attachment list is not ordered like the comments one, by "created" date but alphabetically.

 

Have you gotten a solution so far?

What is the scriptrunner that you used @Sebastian Krzewiński ?

Thanks.

Nic Brough -Adaptavist-
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.
June 19, 2023

This question is a lot out of date, I'd suggest asking a new one.

Like Sebastian Krzewiński likes this