Workflow validator for specific issue type

Fletcher Wu April 6, 2020

I'm looking to add a workflow validator for a Bug issue type only, that makes a custom field (Severity) required. Basically something like If Bug, then Severity is required. Else severity is not required.

3 answers

2 accepted

5 votes
Answer accepted
Thorsten Letschert _Decadis AG_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
April 6, 2020

Hi @Fletcher Wu ,

while this might not be doable out of the box, if evaluating an additional app is applicable for you, I'd like to suggest having a look at Jira Workflow Toolbox.

Given its boolean (or "logical") validators, an expression as simple as this one will do the trick

%{00014} = "Bug" IMPLIES %{10001} != null

where 00014 is the default for issue types and 10001 would have to replaced with the matching Id of your severity field. See other examples for those validators here.

-

Update Feb 18, 2021

Since the latest major release 3.x we've introduced readable field codes resulting in the following expression for the example above:

%{issue.issueType} = "Bug" IMPLIES %{issue.cf10001} != null

Disclaimer: I'm part of the team behind the aforementioned app.

Cheers
Thorsten

Fletcher Wu April 8, 2020

Thanks I can give this a try, I requested from my IT team to try the trial out

2 votes
Answer accepted
Inna Gordin April 8, 2020

Hi @Fletcher Wu ,

Take a look and see if you already have an add on installed, such as ScriptRunner, Jira Workflow Toolbox (as above). Or our app, Jira Misc Workflow Extensions (JMWE). "Field required" validator will help with this issue. The library of validators, conditions, and post-functions will help you extend your workflows and support other use cases. You can try all these apps for free

* * *

From the most recent response below, by David Fischer:

For Jira Server/Data Center:

To make the field mandatory if the issue is a Bug or Defect, you can use a Fields Required Validator (JMWE app), select the mandatory field, and use this Conditional Validation script:

issue.get("issuetype").name in ["Bug","Defect"]

If the issue is not a Bug nor a Defect than use:

!(issue.get("issuetype").name in ["Bug","Defect"])

For Jira Cloud, the same validator use case can be found here.

* * *

Good luck,

Inna

Fletcher Wu April 8, 2020

Hi Inna

My project does have the JMWE extension for "Field required", and I did try this out however I could not figure out how to limit it to a specific Issue Type. I only want my field Severity to be required for Bug issue types, however when I try to add it via JMWE, other issue types also require it. It seems I need to add a conditional validation, however I can't figure out the Groovy expression =( Would you be able to assist me?

Radhika Vijji _Innovalog_
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.
April 8, 2020

Hi Fletcher,

In that case, select the "Conditional Validation" option in the validator, and input the following script:

issue.issuetype.name == "Bug"

Regards,

Radhika

Fletcher Wu April 9, 2020

Thank you @Radhika Vijji _Innovalog_  that worked! Another quick question if I may, if I wanted to set this validator to 2 different issue types (Bug and Content Bug), how would that look? I tried adding 

issue.issuetype.name == "Bug, Content Bug"

 but that didn't work. Also tried them as separate individual validators, but also no luck. Any advice would be appreciated! 

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 9, 2020

Hi Fletcher,

you could do:

issue.issuetype.name in ["Bug", "Content Bug"]
Like # people like this
Fletcher Wu April 14, 2020

Thank you @David Fischer !

srivenkatbabu sinnasami February 16, 2021

Hi All,

i have a specific requirement. I need to have one field should be mandatory during workflow transition but not only for Issue type Bug/Defect. How to apply this?

 

Note: We use common workflow schemes for all projects and issue types.

Regards,

Venkat

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 16, 2021

Hi @srivenkatbabu sinnasami ,

are you on Jira Server/DC or Cloud?

srivenkatbabu sinnasami February 17, 2021

Hi @David Fischer 

I'm on JIRA Server.

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 17, 2021

Hi @srivenkatbabu sinnasami ,

you can use a Fields Required Validator (JMWE app), select the mandatory field, and use this Conditional Validation script:

issue.get("issuetype").name in ["Bug","Defect"]

although I'm not sure if you want to make the field mandatory if the issue is a Bug or Defect, or if the issue is not a Bug nor a Defect. If the latter, use:

!(issue.get("issuetype").name in ["Bug","Defect"])
0 votes
Ed Gaile _Atlanta_ GA_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 6, 2020

Do you have scriptrunner?  If so, you can easily to that via behaviors. 

https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html

Suggest an answer

Log in or Sign up to answer