Hi community,
i'm trying to write a simple validator script to tell that the sum of alll attachments while creating an issue must be < to 1 MB ( for ex ).
I've tested it with an issue key using the script console and it works but not on the create transition validator.
Can you please help me ?
That's my code using an issuekey
import com.atlassian.jira.issue.attachment.Attachment
import com.atlassian.core.util.FileSize
import com.atlassian.jira.issue.Issue
import java.util.*
import com.atlassian.jira.component.ComponentAccessor;
import org.apache.log4j.Logger
import org.apache.log4j.Level
def issuekey = "jira-xxxx"
def issueManager = ComponentAccessor.getIssueManager() ;
def issue = issueManager.getIssueObject(issuekey)
def sum = issue.attachments*.filesize.sum()
def sum1 = sum as Float
sum1 < 1049000.0