How can I put condtion on Resolution field filling (using workflow addon) - Bug workflow in Jira

I have workflow for bug :

Open --> In Progress --> Resolved --> Done     (+ from Open can move to Block and back to Open)

 

Developer handle the bug and at the end move the bug from InProgress --> Resolved and set Resolution to Fix / Rejected / Duplicate .

I wants to have 2 field mandatory to fill in case resolution is Fix but they should be skipp in case of Duplicate / Rejected 

(didn`t find how to do it conditional via Conditions / Validators tabs)

How can I do it ?

 

1 answer

Hi Daniel,

You can use a groovy validator to acheive this functionality. 

As stated in the documentation, the following code can be used to validate fields and make other fields mandatory.

import com.atlassian.jira.issue.Issue
import com.opensymphony.workflow.InvalidInputException
import org.apache.log4j.Category
 
def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
 
Issue myIssue = issue
 
if (myIssue.getResolutionObject().getName() == "Fixed" && ! myIssue.getFixVersions().size()) {
    invalidInputException = new InvalidInputException("fixVersions", "Fix Version/s is required when specifying Resolution of \"Fixed\"")
}

I had similar requirement in the past, where in a custom field must not be empty (that means it should be filled out) if we select resolution value as "fixed". to fullfill this requirement i used the following code : 

 

import com.atlassian.jira.issue.Issue

import com.opensymphony.workflow.InvalidInputException

 

Issue myIssue = issue

if (((myIssue.getResolutionObject().getName() == "Fixed") || ( (cfValues['customfieldname'] == null))
{

invalidInputException = new InvalidInputException("customfield must be empty if Resolution is Fixed")

}

You can tweak this code to have other field also to be mandatory.

Thanks!

 

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Sarah Schuster
Posted Mar 28, 2018 in Jira Software

Can a company’s culture make or break agile adoption?

Can a new-to-agile team survive and thrive in a non-agile culture? If so, what advice would you give to those trying to be agile in a non-agile culture? What's the key(s) to success? Share your thoug...

13,219 views 15 14
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