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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,519
Community Members
 
Community Events
176
Community Groups

[Automation for Jira] Get last added attachment to issue using smart values

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

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?

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.

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

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?

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 Fabrizio Galletti likes this

@Fabrizio Galletti 

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 Fabrizio Galletti likes this
"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 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events