Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

workflow validator: validation on sub-tasks

Rahul Krishna Vangara
Contributor
May 20, 2019

Is there a way to show , which custom mandatory fields are not filled as a validation message in the workflow validations - validation on sub-tasks.

We are able to show a basic message saying

 

Filtering by field values:

^%{11707} != null OR ^%{11729} != null OR ^%{11712} != null OR ^%{11713} != null OR ^%{11714} != null OR ^%{11728} != null OR ^%{10607} != null OR ^%{00003} != null

Message to show when validation fails:

Please press the edit button and fill the mandatory fields in the sub-tasks

 

This message shows when user tries to press the next transition button after creating an issue in the parent task. (we also created sub-tasks based on one field selection automatically in the workflow post-functions)

 

My question , is there any way to display which custom fields need to be filled in which sub-tasks, may be using "advanced" parsing mode instead of "Basic" mode we used above??

 

2 answers

1 accepted

0 votes
Answer accepted
Max Foerster - K15t
Community Champion
May 21, 2019

Hi Rahul,

your use case got me curious here. I'm not saying that it's not possible to provide the information you need during the transition but I'm having a hard time to come up with the best way of displaying the 8 customs fields for X different sub-tasks to the user. Let's just throw in a random number. 5 sub-tasks with 8 missing custom fields each. Sounds like a worst case scenario to have to provide that information in a simple validator error message, right?

So maybe it's worthwhile to tackle this from different angles. You speak of "mandatory" fields. So the first thing that comes to my mind is. Why are mandatory fields not already filled in? Why are you able to create or transition these sub-tasks without providing the necessary information so you have to take care of that when you transition the parent issue. Or maybe I just misunderstood the way your workflow is designed. So you created some sub-tasks and after that try to transition the parent?

Have you tried adding columns to the table displaying the sub-tasks? Or maybe you're already using a third-party app for replacing that view and enhancing it. 

It would be great if you could provide some more background information and then let's see what we can figure out here.

Best, Max

Rahul Krishna Vangara
Contributor
May 29, 2019

we do not need to know which mandatory fields needs to be initialized rather,"we need to show which sub-tasks they have to go and edit the fields(In the validation message)."

Max Foerster - K15t
Community Champion
June 3, 2019

Hi Rahul,

getting the sub-tasks missing the mandatory fields and just returning the issue keys is possible. Please remove the other validator from your transition and choose the boolean validator instead. Here is a suggestion for the validation:

  • We want to validate through a JQL query that all sub-tasks of the current issue ( %{00015} = current issue key) have all mandatory fields distributed. So we're counting the opposite results (NOT all fields filled out) and they have to be 0. Use this expression and customize it according to your fields:
count(issuesFromJQL("parent = " +%{00015}+ " AND NOT ('Custom field1' is not EMPTY AND 'Custom field2' is not EMPTY AND 'Custom field3' is not EMPTY)")) = 0
  • So only when we have 0 sub-tasks left the transition will be executed.
  • For the validation message we want to return the issue keys of the issues lacking the fields:
"Please fill out all mandatory fields in the following sub-tasks: " + toString(issuesFromJQL("parent = " +%{00015}+ " AND NOT ('Custom field1' is not EMPTY AND 'Custom field2' is not EMPTY AND 'Custom field3' is not EMPTY)"))
 

 

The resulting error message will look like this:

error.png

Does this implementation satisfy your need? :)

Best, Max

Like # people like this
Rahul Krishna Vangara
Contributor
June 5, 2019

It works thanks, cool

Like # people like this
Max Foerster - K15t
Community Champion
June 6, 2019

Hey Rahul,

happy to hear that. You're very welcome. If you ever want to take another approach. Think about using a JWT calculated text custom field. It supports (very) basic html, so you could try to build a table and display (with a lot of conditional operators for a field value or none) whether fields have a value or not of each sub-task. Sounds kinda crazy I know! But I think just the fun of trying to implement that would be worth it. :D Never tried it myself.

0 votes
Ravi Varma
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.
May 20, 2019

Hi @Rahul k ,

 

As this is specific to your requirement, you should be exploring either third party apps that suffice your use case or write down your custom validator

References : https://community.atlassian.com/t5/Jira-questions/How-to-create-custom-validators-subtask-must-exist/qaq-p/185553

Rahul Krishna Vangara
Contributor
May 21, 2019

We have Jira workflow toolbox plugin. Is there any possible way to show which custom fields need to be filled in which sub-tasks

Suggest an answer

Log in or Sign up to answer