Workflow Validator Not Working As Expected

I am try to create a workflow validator but instead of getting the message I put in my code I get 

This is my code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkManager
import com.opensymphony.workflow.InvalidInputException
import com.atlassian.jira.issue.IssueFieldConstants
import com.opensymphony.workflow.InvalidInputException
import webwork.action.ActionContext

def issueLinkManager = ComponentAccessor.getComponent(IssueLinkManager)
log.error("Outward Link: " + issueLinkManager.getOutwardLinks(issue.getId()).size())
log.error("Inward Link: " + issueLinkManager.getOutwardLinks(issue.getId()).size())
log.error("All Links: " + issueLinkManager.getIssueLinks(issue.getId()).size())

if (issueLinkManager.getOutwardLinks(issue.getId()).size() > 0){
throw new InvalidInputException("You cannot delete an issue with 1 or more links.")
}

 

Instead it gives me:

It seems that you have tried to perform an illegal workflow operation.

If you think this message is wrong, please contact your JIRA administrators.

2 answers

1 accepted

Do you have any screen configured in your transition?

If you don't have any, message is a little confusing. When you add a screen it will look much better.

 

You can also use Workflow PowerBox Plugin which delivers "Number of related issues validator" you can configure without scripting smile

Thanks.  I can see the error I throw now with my transitions screen.

0 vote

As Robert says, you get this message if you try to add a validator and there is no screen configured. Possibly it only happens when you specify that the error message should be associated with a field. It's a JIRA bug.

Hey Jamie,

Do you know of anyway to remove the default error messages? I want only the message configured in the scripted validators to be shown. Not using condition for this as I want the transition for the workflow to be shown. Using condition will just hide the transition for users outside those roles, can be confusing for new users

 

2018-07-11 16_02_43-Workflow Error - JIRA Development.png

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

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