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

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published Jul 25, 2018 in Marketplace Apps

Jira Cloud and Bitbucket Cloud Integration with Microsoft Teams

One of the newest products in the Microsoft family - Microsoft Teams,  is a chat-based hub for teamwork that integrates all the people, content, and tools your team needs to be more engaged and ...

733 views 0 3
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