Workflow Validator Not Working As Expected

clem
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 9, 2016

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

0 votes
Answer accepted
Robert Dzido
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 9, 2016

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

clem
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 14, 2016

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

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2016

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.

Azfar_Masut July 11, 2018

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

Like Adam Zsiros likes this
Arjun Hazari March 28, 2019

Yes @Robert Dzido  is right on the screen also you can post the error message

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events