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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


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
Community Members
Community Events
Community Groups

Validating Attachments Added this Transition using scriptrunner


Hi everyone,

I'm using this groovy code to validate whether any of attachments added during workflow transition go beyond my allowed size. It works the first time, meaning that it correctly validates that there's an attachment with size that goes over the MAX_ATTACHMENT_SIZE limit, which can be seen on this screen


Screenshot 2022-10-14 150748.png

But when I then removed the file which goes over the limit (merged.pdf) and i try to transition again the validator still fails like this:

Screenshot 2022-10-14 150721.png

What I found out in the log is that the tempWebAttachments variable still holds the merged.pdf even though I removed it from the form. Is there anyway for tempWebAttachments to be up to date, even after I removed/added some attachments?


My validator code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueFieldConstants
import com.atlassian.jira.issue.attachment.TemporaryWebAttachment
import com.atlassian.jira.issue.attachment.TemporaryWebAttachmentManager
import webwork.action.ActionContext

def temporaryAttachmentUtil = ComponentAccessor.getComponent(TemporaryWebAttachmentManager)
def formToken = ActionContext.getRequest()?.getParameter(IssueFieldConstants.FORM_TOKEN)

def MAX_ATTACHMENT_SIZE = 20971520

if (formToken) {
def tempWebAttachments = temporaryAttachmentUtil.getTemporaryWebAttachmentsByFormToken(formToken)
tempWebAttachments.each { it ->
log.debug "Uploaded attachment name: ${it.filename}"
log.debug "Uploaded attachment filesize: ${it.size}"
return tempWebAttachments.every{it -> it.size <= MAX_ATTACHMENT_SIZE}




1 answer

This question was meant for the Jira product section, I apologize. I've already gotten an answer there: 

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events