Forums

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

How to get attachment name when project create

Vincent Lee August 12, 2021

Hi 

I want to validate the attachment name when user create issue.

If the attachment name is not valid, they can not create issue.

And below is my code.


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




def attachmentDirectoryAccessor = ComponentAccessor.getComponent(FileSystemAttachmentDirectoryAccessor)
File temporaryAttachmentDirectory = attachmentDirectoryAccessor.getTemporaryAttachmentDirectory()
def newAttachmentNames = issue.modifiedFields.get(IssueFieldConstants.ATTACHMENT)?.newValue[0]
def fileName = new File(temporaryAttachmentDirectory, newAttachmentNames as String).getName()

 

But the value will like 'temp1337765752408737186'.

How to get real attachment name when project create.

 

0 answers

Suggest an answer

Log in or Sign up to answer