Hey guys,
Jira users want to see the list of attachments based on reverse time. My code is
if (attachments){
for (attachment in attachments.reverse()) {
if(count>0){
text+='\n'
}
text+= attachment.getCreated().format('dd/MM/yyyy HH:mm:ss') + ": " + attachment.getId().toString()
count+=1
}
def rendererManager = ComponentAccessor.getComponent(RendererManager.class)
def fieldLayoutItem = ComponentAccessor.getFieldLayoutManager().getFieldLayout(issue).getFieldLayoutItem("attachment")
def renderer = rendererManager.getRendererForField(fieldLayoutItem)
renderer.render(text, null)
}
The result is:
Timestamp Id
------------ -----
22/02/2022 21:49:07: 17354
22/02/2022 21:49:12: 17353
22/02/2022 21:49:09: 17352
Which means the order is based on attachment id. Please, how can I order them based on creation time? Thanks!
Almu