Forums

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

Attachments cannot be checked in the validator

James Lebron
Contributor
November 8, 2022

Hello, community

I have a big problem. In the workflow, I added a custom validator whose purpose is to check if the attachment is uploaded.

Here's a fairly common line of code I wrote:

def attachments = issue.getAttachments()
log.warn("attachments size: ${attachments.size()}")
But I'm wondering why I added a screen to the workflow transition and I've uploaded the attachment, but it's not available in the validator.

1 answer

0 votes
Vikrant Yadav
Community Champion
November 8, 2022

Hi @James Lebron  Try to add Scripted Validator :- 

It check Attachment should be empty. Atleast one attachment is mandatory.

import com.atlassian.jira.component.ComponentAccessor

ComponentAccessor.attachmentManager.getAttachments(issue).size() > 0
James Lebron
Contributor
November 8, 2022

Thank you for your advice, but unfortunately, this code and my code execute the same result, both are empty.

During the workflow transition, I uploaded the attachment, but it was still not available in the validator

I wonder if it has something to do with an attachment  plug-in named ‘SMART ATTACHMENTS’ I use? 

Vikrant Yadav
Community Champion
November 8, 2022

Hi @James Lebron  In my code, you won’t be able to transition the issue until you attach at least one attachment. When you attach an attachment , you won’t get an error message and issue get transitioned. 
In this you no need to attach transition screen, it works without transition screen. Give error message on view screen. 
I am using Scriptrunner plug-in >> Scripted Validator.

 

Thanks

Suggest an answer

Log in or Sign up to answer