Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

[Scriptrunner Cloud] How to access the issue in Script Listener with "Attachment Created" Event?

Guido Scollo September 26, 2025

How can I access to the issue where was attached a file in a listener with "Attachment Created" Event?

 

Thank you!

Guido

3 answers

1 accepted

1 vote
Answer accepted
Kristian Walker _Adaptavist_
Community Champion
September 26, 2025

Hi Guido,

Unfortunately, the Attachment Created event does not provide the Issue Key in its bindings. 

The reason is that the webhook event is sent back when an attachment comes from Atlassian, and they don't provide the issue object in the event they send back. 

This means you won't be able to get the issue key. You'll need to use a different event, such as Issue Updated, and check the changelog to see if the attachment field was updated, if you need the issue key.

I hope this information helps.

Regards,

Kristian

 

Guido Scollo September 26, 2025

Hi Kristian,

I have found a workaround, but this looks better. I'll try.

 

Thank you!

Guido

0 votes
Guido Scollo September 26, 2025

I have found a workaround, but it is not a best practice.

 

I create a listener on "Comment Created" event, rather than "Attachment Created".

 

In this case, I must add the attachments using comments.

Then, using the variable issue, I can access to all the attachments, and I can find all the attachments created in the last 5 minutes (but is enougth in the last 60 seconds).


def attachments = currentIssue.attachments
.findAll { it.author != '712020:14398473-d063-48cf-b14b-1e11d2fbb0f9' }
.findAll { attach ->
    def createdTime = LocalDateTime.parse(attach.created, "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
    def nowTime = LocalDateTime.now(ZoneId.of("Europe/Rome"))
    Duration.between(createdTime, nowTime).getSeconds() < 300
}

 

0 votes
Florian Bonniec
Community Champion
September 26, 2025

Hi

 

I did not find any way to get this information, The only variable available in that event are

config, logger, baseUrl, event, eventId, attachment, webhookEvent, timestamp

None of them have the issue id or key

Regards

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
ENTERPRISE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events