You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
Hi, I have used Field(s) changed validator "attachment" but it is not making the field mandatory.
Then I have used script validator using condition below:
import com.atlassian.jira.component.ComponentAccessor
ComponentAccessor.attachmentManager.getAttachments(issue).size() = 0
This is not letting me submitting the form as the error message is displaying.
Is there any solution?
Thanks
Swarna
Hello @Swarna Radha
You can create custom script validator to achieve this.
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
import com.opensymphony.workflow.InvalidInputException
def temporaryAttachmentUtil = ComponentAccessor.getComponent(TemporaryWebAttachmentManager)
def formToken = ActionContext.getRequest()?.getParameter(IssueFieldConstants.FORM_TOKEN)
if (formToken) {
def tempWebAttachments = temporaryAttachmentUtil.getTemporaryWebAttachmentsByFormToken(formToken)
tempWebAttachments.each { TemporaryWebAttachment it ->
log.error("Uploaded attachment name: ${it.filename}")
}
if(!tempWebAttachments){
throw new InvalidInputException(IssueFieldConstants.ATTACHMENT,
"You must upload attachment")
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Swarna Radha
Please use the following instead with simple script validator:
import com.atlassian.jira.component.ComponentAccessor
ComponentAccessor.attachmentManager.getAttachments(issue).size() >= 1
I hope this will help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any option to check if the no of attachments are 4 in number.
and for a specific transition.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The solution for the SimpelScriptValidator ends every time in a NullPointerException.
The solution above for the custom script validator works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This checks, if a issue has something attached. But during the transition the attachment is not yet been attached. This is the reason why the TemporaryWebAttachmentManager has to be used.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.