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

This widget could not be displayed.

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.

This widget could not be displayed.

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
Community showcase
Posted yesterday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

33 views 0 1
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