Validating Attachments Added this Transition

I have a requirement to validate if attachments were added during a transition screen where the attachment field exists. I have followed the code Ref: https://scriptrunner.adaptavist.com/latest/jira/recipes/workflow/validators/validate-attachments-links-in-transition.html#_validating_attachments_added_this_transition but that's not working. Can someone please confirm if that works even or if there are any caveats while using that.

2 answers

1 accepted

Accepted Answer
1 vote

I have worked around the above issue as below:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueFieldConstants
import com.atlassian.jira.issue.attachment.FileSystemAttachmentDirectoryAccessor

def attachmentDirectoryAccessor = ComponentAccessor.getComponent(FileSystemAttachmentDirectoryAccessor)
def temporaryAttachmentDirectory = attachmentDirectoryAccessor.getTemporaryAttachmentDirectory()

def attachmentNames = issue.modifiedFields.get(IssueFieldConstants.ATTACHMENT)?.newValue

if(attachmentNames) {
return true
0 votes
Jenna Davis Community Champion Dec 19, 2017

Hello, 

What are your JIRA and ScriptRunner versions?

Jenna

Hi Jenna,

Jira is 7.3 while Scriptrunner is 5.1.6

 

Thanks,

Madhu

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

21,280 views 2 7
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you