It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Get last added attachment to issue with Scriptrunner Edited

Hi

I need to get from the issue last added attachment. Do you know how I can achieve this? I'm able to get list of issue attachemnts but this list is sorted by name.

 

Regards,

Seba

1 answer

1 accepted

1 vote
Answer accepted

Just sort the attachment collection by created attribute:

import com.atlassian.jira.component.ComponentAccessor
def im = ComponentAccessor.issueManager
def am = ComponentAccessor.attachmentManager
def issue = im.getIssueObject('JSP-4736')
am.getAttachments(issue).sort{it.created}.last()

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Align

Best Practices in Jira Align

Hello Jira Align customers! In order to better serve you on your journey with Jira Align, the Community team has worked with the Jira Align team to curate the content in this collection to better s...

100 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you