How to create custom validators - subtask must exist

I thought i might be able to use validators to ensure that i can enforce the existence of a subtask before an issue (story type) reaches a particular step in the workflow.

However the ADD VALIDATOR option is limited to 3 options below.

- Complete Session Validator Validates that all Bonfire test sessions related to this issue are complete.

- Permission Validator Validates that the user has a permission.

- User Permission Validator Validates that the user has a permission, where the OSWorkflow variable holding the username is configurable. Obsolete.

How do i get about creating a custom validator, and can the validation 'subtask must exist' be created? (ps: i checked conditions, but all conditions checks is the status of a subtask, so that if no subtask exists, status cannot be checked)

5 answers

1 accepted

1 vote
Accepted answer

I have a very similar validator implemented, but is not the same case. In my case the validator check if the task (have subtasks AND they are all closed ) OR ( no subtasks at all).

Try searching in marketplace, it seems a pretty common use case and you can get this done.

Or, you can create a plugin as a workflow validator, to check if there are subtasks. The code is somewhat like:

public class CheckSubtastks implements Validator {

	public void validate(Map transientVars, Map args, PropertySet ps) throws InvalidInputException, WorkflowException {

		boolean validate = false;
		Issue issue = (Issue) transientVars.get("issue");

		int subtareas = issue.getSubTaskObjects().size();

		if (subtareas == 0) {
			validate = false;
			throw new WorkflowException("Define some subtasks to go ...");


1 vote

You are on the right track - that's exactly what validators are for.

However, Jira does not ship with very many of them. Most of us install add-ons to get some of the more basic validators (that really should be included in the core in my humble opinion) - the Jira Suite utilities is the one I usually reach for first. There are a lot of other validators in the marketplace too.

If you can't find one that matches, then you'll need to write one. I do this in two ways:

1. Write one as a plugin

2. Add the script runner add-on - it provides a framework that saves you having to write all the structure around your own plugin, you can get stuck straight into the code.

Hi Laurence,

Through this plugin guide you can create your custom validator plugin :

in the validator , you can have your own logic of validation.

Another important: condition is basically used for user permission (through these we can specific who all can see the transition).

thanks guys,

i am so impressed by the quick feedback, so many times i got stranded with Atlassian generic answers, that totally beats it.

i am usually a bit dubious about finding 'solutions' to my issues on marketplace, but with the reassurance that it might be a common use case, i downloaded and that particular use case was in there, so that i didn't have to code at all!

Happy :)

ps: might not work for everyone as it is a paid solution, however i am on a community license, so that is good enough for me

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,774 views 18 21
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