Edit Validation Did Not Worked



I've added following code for behaviour plugin. I tried returning nothing, throwing invalid input exception and finally below code returning the error collection. Error occurs but jira completes edit operation successfully instead it should remain at Edit screen and show the error message added in the code. 

JIRA Version: 7.4.3

Script Runner: 5.1.6


-thank you very much


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.util.SimpleErrorCollection
import org.slf4j.Logger
import org.slf4j.LoggerFactory

Issue issue=(Issue) issue

final String TESPIT_ISSUE_TYPE_NAME="Tespit"
final String ILGILI_TESPITLER_FIELD_NAME="İlgili Tespitler"
final Logger LOG=LoggerFactory.getLogger("tr.gov.tubitak.bilgem.yte.jira.groovy.validators.epid.EPIDIlgiliTespitlerForEditValidator")
CustomFieldManager cfm=ComponentAccessor.getCustomFieldManager()
Collection<CustomField> customFieldCollection=cfm.getCustomFieldObjectsByName(ILGILI_TESPITLER_FIELD_NAME)
SimpleErrorCollection errorCollection = new SimpleErrorCollection()
if(customFieldCollection==null || customFieldCollection.size()!=1) {
errorCollection.addError(ILGILI_TESPITLER_FIELD_NAME,ILGILI_TESPITLER_FIELD_NAME+" alanı bulunamadı veya hatalı, sistem yöneticisine başvurunuz.")
return errorCollection

CustomField ilgiliTespitlerField=customFieldCollection.iterator().next()
Object object=issue.getCustomFieldValue(ilgiliTespitlerField)
if(object!=null) {
List<String> issueKeyList=(List<String>) object
List<String> invalidIssues=new ArrayList<String>()
IssueManager issueManager = ComponentAccessor.getIssueManager()
for(String issueKey:issueKeyList) {
Issue linkedIssue=issueManager.getIssueByCurrentKey(issueKey)
if(!linkedIssue.getIssueType().getName().equals(TESPIT_ISSUE_TYPE_NAME)) {
if(invalidIssues.size()>0) {
LOG.error("Invalid issues exists, size: "+invalidIssues.size())
StringBuffer buffer=new StringBuffer()
buffer.append(ILGILI_TESPITLER_FIELD_NAME+" alanına sadece '"+TESPIT_ISSUE_TYPE_NAME+"' türünde talep seçilebilir:")
boolean first=true
for(String invalid:invalidIssues) {
buffer.append(" ,")
else {
buffer.append(" ")
first = false
buffer.append(invalid + "\n")
return errorCollection



1 answer

Hey Yusuf, 

According to the documentation, to disallow the transition you throw a new InvalidInputException (com.opensymphony.workflow.InvalidInputException).

regards, Thanos

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,687 views 3 11
Read article

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